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 (February 2007)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 3 Feb 2007 02:39:05 -0800
Reply-To:     Albert-jan Roskam <fomcl@yahoo.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Albert-jan Roskam <fomcl@yahoo.com>
Subject:      Re: Recoding
Comments: To: Chen Wei <weichen@ruc.edu.cn>
In-Reply-To:  <001d01c746f6$defa6740$0301a8c0@f95acc423a4c451>
Content-Type: text/plain; charset=iso-8859-1

Hi Wayne,

Example 1 (untested!): VECTOR age(49). /* creation of 49 empty age vars. VECTOR v_age=age1 TO age49. /* definition of vector/array 'v_age'. LOOP #I=1 TO 49. + IF (age = #I) v_age(#I) = 1. + IF (age ne #I) v_age(#I) = 0. END LOOP. EXE.

--> as you mentioned already, a macro loop would also be an option. Are you sure you want all values not being #i to be recoded to 0 -- INCLUDING MISSING VALUES? If so, you could make it easier just by replacing the IF rules with: COUNT v_age(#I) = age (#I).

If not, just add a rule that retains the original missing values (user and/or system missing values).

Cheers! Albert-Jan

--- Chen Wei <weichen@ruc.edu.cn> wrote:

> Hi, > > I am a biginner in using SPSS, I am creating dummy > variables and recoding some categorical variables. > These are easy to do with the following syntax, but > I will need to repeat 35 times doing the same thing. > Could anyone sugest how to use Vector and Loop > Structure or Macro to do the job? Thanks very much. > > Wayne > > ************************** > *Example 1 > > if(age=15)age15=1. > if(age~=15)age15=0. > > if(age=16)age16=1. > if(age~=16)age16=0. > ...... > if(age=49)age49=1. > if(age~=49)age49=0. > ************************** > *Example 2 > > do if yage15<2000. > recode marry15 to marry49 (0=1). > end if. > execute. > > do if yage16<2000. > recode marry16 to marry49 (0=1). > end if. > execute. > ...... > do if yage49<2000. > recode marry49 (0=1). > end if. > execute. > ************************** > *Example 3 > > do if > ((yage15=par1)|(yage15=par2)|(yage15=par3)|(yage15=par4)|(yage15=par5)|(yage15=par6)|(yage15=par7)|(yage15=par8)). > recode child15 (0=1). > end if. > execute. > > do if > ((yage16=par1)|(yage16=par2)|(yage16=par3)|(yage16=par4)|(yage16=par5)|(yage16=par6)|(yage16=par7)|(yage16=par8)). > recode child16 (0=1). > end if. > execute. > ...... > do if > ((yage49=par1)|(yage49=par2)|(yage49=par3)|(yage49=par4)|(yage49=par5)|(yage49=par6)|(yage49=par7)|(yage49=par8)). > recode child49 (0=1). > end if. > execute. > *************************** >

____________________________________________________________________________________ No need to miss a message. Get email on-the-go with Yahoo! Mail for Mobile. Get started. http://mobile.yahoo.com/mail


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