|
Hi all,
This one might have been asked before. I received a household data set. Each record represents a household, and each question has 15 variables (one for each potential household member). I want to transform the data so that each household member is a record and each record preserves the household number and the number of the household member in the household. Is there anyway do this efficiently? Thanks, Mark ====================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 |
|
Hi Mark,
You can save all variables for each member in a separate file, rename all the common variables into the same name, add all these files together (keep all vars that you want to retain ie. Demographics vars). Try out the following syntax (supposed you have 5 members in a family): define !sav (!pos !charend('/')/ !pos !charend('/')/ !pos !charend('/')). compute member=!2. save outfile !1 / keep ID d1 to d10 member !3 /rename (!3 =var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12 var13 var14 var15). !enddefine. !sav 'C:\temp1.sav' / 1 / m1_var1 m1_var2 m1_var3 m1_var4 m1_var5 m1_var6 m1_var7 m1_var8 m1_var9 m1_var10 m1_var11 m1_var12 m1_var13 m1_var14 m1_var15. !sav 'C:\temp2.sav' / 2 / m2_var1 m2_var2 m2_var3 m2_var4 m2_var5 m2_var6 m2_var7 m2_var8 m2_var9 m2_var10 m2_var11 m2_var12 m2_var13 m2_var14 m2_var15. !sav 'C:\temp3.sav' / 3 / m3_var1 m3_var2 m3_var3 m3_var4 m3_var5 m3_var6 m3_var7 m3_var8 m3_var9 m3_var10 m3_var11 m3_var12 m3_var13 m3_var14 m3_var15. !sav 'C:\temp4.sav' / 4 / m4_var1 m4_var2 m4_var3 m4_var4 m4_var5 m4_var6 m4_var7 m4_var8 m4_var9 m4_var10 m4_var11 m4_var12 m4_var13 m4_var14 m4_var15. !sav 'C:\temp5.sav' / 5 / m5_var1 m5_var2 m5_var3 m5_var4 m5_var5 m5_var6 m5_var7 m5_var8 m5_var9 m5_var10 m5_var11 m5_var12 m5_var13 m5_var14 m5_var15. exe. add files file 'C:\temp1.sav'/ file 'C:\temp2.sav'/ file 'C:\temp3.sav'/ file 'C:\temp4.sav'/ file 'C:\temp5.sav'. select if (nvalid(var1 to var15)<>0). save outfile 'c:\All members-data.sav'. exe. Cheers, Hop ----- Original Message ----- From: "Mark.W.Andrews" <[hidden email]> To: <[hidden email]> Sent: Friday, April 18, 2008 12:19 AM Subject: Restructuring Data File Hi all, This one might have been asked before. I received a household data set. Each record represents a household, and each question has 15 variables (one for each potential household member). I want to transform the data so that each household member is a record and each record preserves the household number and the number of the household member in the household. Is there anyway do this efficiently? Thanks, Mark ======= 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 ===================== 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 Mark.W.Andrews-2
A brute force method would be to use a loop and write a record for each
member variable if not missing. A more elegant method might be to use VARSTOCASES That's where I would start. Dennis Deck, PhD RMC Research Corporation 111 SW Columbia Street, Suite 1200 Portland, Oregon 97201-5843 voice: 503-223-8248 x715 voice: 800-788-1887 x715 fax: 503-223-8248 [hidden email] -----Original Message----- From: Mark.W.Andrews [mailto:[hidden email]] Sent: Thursday, April 17, 2008 9:20 AM Subject: Restructuring Data File Hi all, This one might have been asked before. I received a household data set. Each record represents a household, and each question has 15 variables (one for each potential household member). I want to transform the data so that each household member is a record and each record preserves the household number and the number of the household member in the household. Is there anyway do this efficiently? Thanks, Mark ===================== 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 |
