"Starts with" shorthand?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"Starts with" shorthand?

Laflamme, David
In SAS, "=:" means "starts with".  Is there a shortcut like this available in SPSS?  I realize that SUBSTR and other options are available in both programs.

Example:  In a health claims database, to find all principal diagnosis codes beginning with "3050" and allowing any (or no) 5th digit:

In SAS -->  IF prindiag=: '3050' THEN var1=1;

In SPSS -->  IF SUBSTR(prindiag,1,4) = '3050' var1=1.

Thanks in advance.

-David

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: "Starts with" shorthand?

Oliver, Richard
The INDEX function, as in:

data list list /var1 (a10).
begin data
3050abc
3052abc
3050def
3053abc
3050ghi
end data.
compute newvar=index(var1, "3050")=1.
list.

*index(var1,"3050")=1 returns true if the value begins with 3050.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Laflamme, David
Sent: Monday, September 21, 2009 9:34 AM
To: [hidden email]
Subject: "Starts with" shorthand?

In SAS, "=:" means "starts with".  Is there a shortcut like this available in SPSS?  I realize that SUBSTR and other options are available in both programs.

Example:  In a health claims database, to find all principal diagnosis codes beginning with "3050" and allowing any (or no) 5th digit:

In SAS -->  IF prindiag=: '3050' THEN var1=1;

In SPSS -->  IF SUBSTR(prindiag,1,4) = '3050' var1=1.

Thanks in advance.

-David

=====================
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