Hi all,
I'm wondering how I would go about recoding string variables based on a match algorithm. For example, I have a dataset with a few hundred cases that read "ASCI.AFI". Is there a way to organize all of those cases into a new variable (group) that codes every "ASCI.AFI" case as a 1? (In the new "group" variable). I've tried "IF var1=ASCI.AFI group=1", however it doesn't seem to like the string variables. Any thoughts? Thank you! |
Administrator
|
IF var1="ASCI.AFI" group=1.
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 Darko_Giac
I may be simpler to (untested)
AUTORECODE Variables= mystring /Into mynumeric /print. Then if alphabetical order of the groups is not quite what you want RECODE mynumeric (...) (...) INTO mygroups.
Art Kendall
Social Research Consultants |
In reply to this post by Darko_Giac
You've had replies to this already. I'm surprised those didn't help although it seemed there confusion over your terminology. Here's my two pfennings.
If this is your statement, then it is wrong. IF var1=ASCI.AFI group=1 It should be IF var1="ASCI.AFI" group=1. or IF var1='ASCI.AFI' group=1. Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Darko_Giac Sent: Monday, October 17, 2016 6:58 PM To: [hidden email] Subject: If statements and String variables Hi all, I'm wondering how I would go about recoding string variables based on a match algorithm. For example, I have a dataset with a few hundred cases that read "ASCI.AFI". Is there a way to organize all of those cases into a new variable (group) that codes every "ASCI.AFI" case as a 1? (In the new "group" variable). I've tried "IF var1=ASCI.AFI group=1", however it doesn't seem to like the string variables. Any thoughts? Thank you! -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/If-statements-and-String-variables-tp5733286.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 |
Note that the other condition will be missing unless it is defined as (say) 0 or 2.
To get both Yes and No defined in one line, you can use
COMPUTE Group= (var1 eq "ASCI.AFI"). It is acceptable to use "=" for "eq" but I think using eq or EQ is easier to read. -- Rich Ulrich From: SPSSX(r) Discussion <[hidden email]> on behalf of Maguin, Eugene <[hidden email]>
Sent: Tuesday, October 18, 2016 9:35 AM To: [hidden email] Subject: Re: If statements and String variables You've had replies to this already. I'm surprised those didn't help although it seemed there confusion over your terminology. Here's my two pfennings.
If this is your statement, then it is wrong. IF var1=ASCI.AFI group=1 It should be IF var1="ASCI.AFI" group=1. or IF var1='ASCI.AFI' group=1. Gene Maguin |
Free forum by Nabble | Edit this page |