Hi,
In a script, I would like SPSS to look for a range of string values, specifically the value could be '09.4^^^', but not all 3 spaces have to be used. I.e., the value could be '09.4' or '09.41' or '09.41A' or '09.41AA'. Is there a symbol I can use to specify this? Thanks! ===================== 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 |
If you're just looking to see if the string
exists:
compute stringexists=index(stringvar, '0.94')>0. The value of the new variable will be 1 for all cases in which the the string variable contains '0.94', and 0 for all other cases. From: Alexa <[hidden email]> To: [hidden email] Date: 09/23/2011 11:40 AM Subject: String value truncation Sent by: "SPSSX(r) Discussion" <[hidden email]> Hi, In a script, I would like SPSS to look for a range of string values, specifically the value could be '09.4^^^', but not all 3 spaces have to be used. I.e., the value could be '09.4' or '09.41' or '09.41A' or '09.41AA'. Is there a symbol I can use to specify this? Thanks! ===================== 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 |
Administrator
|
In reply to this post by Alexa
Alexa,
How about '109.4' ? I presume you would wish to exclude that. In such case Rick's simple use of INDEX (posted above) will fail to reject. You probably want to use SUBSTR function COMPUTE Found=SUBSTR(yourstringvar,1,4) EQ '09.4'. (the newfangled version would be CHAR.SUBSTR(...). Anticipating that there might be more than one of these and perhaps you wish differing lengths consider DO REPEAT needle="09.4" "100.5" ".9" /SLEN= 4 5 2 / result = @A @B @C. + COMPUTE result= SUBSTR(yourstringvar,1,SLEN) EQ needle. END REPEAT. HTH, David
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?" |
Free forum by Nabble | Edit this page |