Please, how to work recode in the next code?
DO IF (h1bmaish8b >= 30) . RECODE H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=SYSMIS) . END IF . EXECUTE . Thanks in advance. |
Administrator
|
My ESP is failing me today.
It would be helpful if you were to state what you want to achieve rather than relying on mind reading tricks?
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?" |
First off H11_1 thru h12 need to be adjacent and in the order you specified
below in the dataset. Then you can use do repeat like so: Do repeat h = h11_1 to h12. if (h1maish8b >= 30) h = $sysmis. End repeat. Exe. This will replace h11_1 to h12 with system missing whenever h1maish8b >=30. A word of advice, if this is the original dataset it's not really good practice to replace the values of a variable. It would be better to create a new variable like so: Numeric h_revised11_1 to h_revised11_7(f8.2). *# or however long this variable needs to be. Numeric h_revised12. *# Not clear why this variable name is dissimilar to the other variable names but I'm just guessing based on the literal interpretation of what you provided. And all of these newly created numeric variables must also be in this order adjacent in the dataset. Do repeat h = h11_1 to h12 /h_revised = h_revised11_1 to h_revised12. If (h1maish8b >=30) h_revised = $sysmis. If (h1maish8b < 30) h_revised = h. *include this to copy over values from original h variables. End repeat. Exe. Thanks Matt -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso Sent: Sunday, December 19, 2010 11:25 AM To: [hidden email] Subject: Re: Use of Recode... My ESP is failing me today. It would be helpful if you were to state what you want to achieve rather than relying on mind reading tricks? osvaldobaeza wrote: > > Please, how to work recode in the next code? > > DO IF (h1bmaish8b >= 30) . > RECODE > H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=SYSMIS) . > END IF . > EXECUTE . > > Thanks in advance. > > > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Use-of-Recode-tp3310946p331135 2.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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 osvaldobaeza
What problem are you having?
Does the second block of syntax come closer to what you want? Do you perhaps want to copy a larger number of variables so the the TO convention works? It is poor programming to have SYSMIS appear on the right hand side of a transformation. The result should be user missing because the user set it that way. The result is not missing due to the system being unable to follow your instructions. SYSMIS means "SYStem MISsing". it is usually poor programming to write over values. You will inevitably refine what you are telling the computer to do and you want to preserve the ability go back and do IT better. Using poor programming practices does not always come back to bite you, but it frequently does. [SPSS suggestion - perhaps options could be built in to warn when something that is poor programming is detected, like recoding or other transformations with sysmis on the right hand side. Or writing over values. ] Open a new instance of SPSS. Copy and past the syntax below into a syntax window. Run it. Compare the two sets of results. Art Kendall Social Research Consultants new file. data list list/ h1bmaish8b (f2) h11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (8f3). begin data. 27 1 2 3 4 5 6 7 8 28 2 3 4 5 6 7 8 1 29 3 4 5 6 7 8 1 2 30 4 5 6 7 8 1 2 3 31 5 6 7 8 1 2 3 4 end data. dataset name yourway list. DO IF (h1bmaish8b >= 30) . RECODE H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=SYSMIS) . END IF . list. data list list/ h1bmaish8b (f2) h11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (8f3). begin data. 27 1 2 3 4 5 6 7 8 28 2 3 4 5 6 7 8 1 29 3 4 5 6 7 8 1 2 30 4 5 6 7 8 1 2 3 31 5 6 7 8 1 2 3 4 end data. dataset name better. list. DO IF (h1bmaish8b GE 30) . RECODE H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=-1) into rH11_1 rH11_2 rH11_3 rH11_4 rH11_5 rH11_6 rH11_7 rh12. ELSE. RECODE H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=copy) into rH11_1 rH11_2 rH11_3 rH11_4 rH11_5 rH11_6 rH11_7 rh12. END IF . missing values rH11_1 rH11_2 rH11_3 rH11_4 rH11_5 rH11_6 rH11_7 rh12 (-1). formats rH11_1 rH11_2 rH11_3 rH11_4 rH11_5 rH11_6 rH11_7 rh12 (f2). list. On 12/19/2010 12:03 AM, osvaldobaeza wrote: ===================== 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 REFCARDPlease, how to work recode in the next code? DO IF (h1bmaish8b >= 30) . RECODE H11_1 H11_2 H11_3 H11_4 H11_5 H11_6 H11_7 h12 (ELSE=SYSMIS) . END IF . EXECUTE . Thanks in advance. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Use-of-Recode-tp3310946p3310946.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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
Art Kendall
Social Research Consultants |
Free forum by Nabble | Edit this page |