|
I'm wanting to restructure a dataset such that I need to apply something like this: VARSTOCASES /MAKE Q1 from Q1_01 to Q1_99 /MAKE Q2 from Q2_01 to Q2_99
/MAKE Q3 from Q3_01 to Q3_99 /MAKE Q4 from Q4_01 to Q4_99 /MAKE Q5 from Q5_01 to Q5_99 X1_01 TO X1_99 Y1_01 TO Y1_99 Z1_01 TO Z1_99. To achieve this I need to create 3 sets of dummy variables for each Q1 to Q4 (as for each MAKE in VARSTOCASES must contain the same number of variables). To avoid this I'm wondering if the desired result can be reached some other way?
Many thanks in advance, Jignesh |
|
Administrator
|
You are not describing whatever issue you are having with any clarity.
Try try again! Beginning? Middle? End?
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
|
In reply to this post by Jignesh Sutar
I can think of no easier way - at least not any easier than building fake variables. One possibility may be to use one big VARSTOCASES - something like
VARSTOCASES /MAKE Q FROM Q1_01 TO Z1_99 /INDEX Id (Q). And then rebuild the ID to suit your fancy for a CASESTOVARS to reshape the variables back in different columns. Another idea is to make seperate datasets, do the VARSTOCASES in each uniquely and then merge them back together if need be. Both of these will likely take more time and code to accomplish the same end result as the dummy variable approach you mention. Without any context this ends up being a pretty strange way to store your data though, as for the Q variables you will basically have missing values by "data storage design". I can imagine I'm ignorant - but I've never come across a situation in which that is desirable (and is most of the time an outcome of poor database design/normalization in my experience). |
|
In reply to this post by Jignesh Sutar
Why?
But it looks like you can put out X1_01 to Z1_99 as a separate file that has only variable Q5 by using one VarsToCases; put out all the Q variables using the sensible VarsToCases; and then ADD FILES. -- Rich Ulrich Date: Tue, 4 Mar 2014 12:25:12 +0000 From: [hidden email] Subject: Alternative ways to stack a dataset To: [hidden email] I'm wanting to restructure a dataset such that I need to apply something like this: VARSTOCASES /MAKE Q1 from Q1_01 to Q1_99 /MAKE Q2 from Q2_01 to Q2_99
/MAKE Q3 from Q3_01 to Q3_99 /MAKE Q4 from Q4_01 to Q4_99 /MAKE Q5 from Q5_01 to Q5_99 X1_01 TO X1_99 Y1_01 TO Y1_99 Z1_01 TO Z1_99. To achieve this I need to create 3 sets of dummy variables for each Q1 to Q4 (as for each MAKE in VARSTOCASES must contain the same number of variables). To avoid this I'm wondering if the desired result can be reached some other way?
Many thanks in advance, Jignesh |
|
In reply to this post by Jignesh Sutar
At 07:25 AM 3/4/2014, Jignesh Sutar wrote:
>I'm wanting to restructure a dataset such that I need to apply >something like this: > >VARSTOCASES > /MAKE Q1 from Q1_01 to Q1_99 > /MAKE Q2 from Q2_01 to Q2_99 > /MAKE Q3 from Q3_01 to Q3_99 > /MAKE Q4 from Q4_01 to Q4_99 > /MAKE Q5 from Q5_01 to Q5_99 > X1_01 TO X1_99 > Y1_01 TO Y1_99 > Z1_01 TO Z1_99. The first question is, what structure do you want the final dataset to have? Assuming that each of the TO lists represents 100 variables, as they seem to, it looks like you want to create 400 cases from each case in the original file; and the new file contains variables Q1, Q2, Q3, Q4, and Q5. It's clear enough what the first 100 records from each original record should be: Q1-Q5 should have the values from what I'll call the Q1 group (Q1_01 TO Q1_99) through the Q5 group (Q5_01 to Q5_99) respectively. But what about the remaining 300 records? You seem to want Q5 to go on, taking data from the X1 group for 100 records, from the Y1 group for 100 records, and the Z1 group for the last 100 records. OK; but, what values should Q1 to Q4 have in those records? Missing? Or, repeat their values from the initial 100 records, in sequence? Or, what? The problem isn't the VARSTOCASES syntax; that can be solved, once we know what effect you're trying to get. (By the by, it isn't clear that you have identifying information in your original records. You should, and that identifying information needs to remain in the restructured data. Also, you should have an INDEX subcommand on the VARSTOCASES, so you can trace back any record in the restructured file to which record *and variables* it came from in the original file.) ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Jignesh Sutar
In previous post, for "100" read "99"; for "400" read "396"; etc.
-Sigh Richard ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
