LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 Apr 2008 17:05:33 +0800
Reply-To:     Hop <thienhop@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Hop <thienhop@gmail.com>
Subject:      Re: Restructuring Data File
Comments: To: "Mark.W.Andrews" <Mark.W.Andrews@MACROINTERNATIONAL.COM>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
              reply-type=original

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" <Mark.W.Andrews@MACROINTERNATIONAL.COM> To: <SPSSX-L@LISTSERV.UGA.EDU> 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 LISTSERV@LISTSERV.UGA.EDU (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 LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page