|
Hi SPSS user,
Can someone tell me if SPSS has a function (similar to SAS %scan) that can search an argument (or string of variable names separated by ' ') and return the nth name. Below is an example of what I am trying to do using SAS code. %do i = 1 %to 5; %let varname = %scan(&varlist,&i, ' '); %end. Thanks in advance for your help. |
|
See below. Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Hi SPSS user, Can someone tell me if SPSS has a function (similar to SAS %scan) that can search an argument (or string of variable names separated by ' ') and return the nth name. Below is an example of what I am trying to do using SAS code. %do i = 1 %to 5; %let varname = %scan(&varlist,&i, ' '); %end. Thanks in advance for your help. >>>SPSS does not have a built-in function like this, although you could write a DO with the index and substr functions. Here is a way to do it with the SPSSINC TRANS extension command, which requires the Python programmability plugin and at least Version 17. The extension command, which also includes a dialog box interface, and the plugin can be downloaded from SPSS Developer Central, www.spss.com/devcentral. SPSSINC TRANS RESULT=v1 v2 v3 v4 v5 TYPE=20 20 20 20 20 /FORMULA string.split(str). This creates five new variables, v1, ... v5, each a string of length 20, by applying the specified formula to the string variable named str. If there are fewer values found than the number of variables, the result will be blank. If there are more, it is an error. SPSSINC TRANS can apply any Python function to variables in the SPSS case data. HTH, Jon Peck -- View this message in context: http://old.nabble.com/search-argument-and-return-the-nth-name-tp26512871p26512871.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 |
|
Hi Jon,
Thanks for the suggestion - will give it a go.
|
| Free forum by Nabble | Edit this page |
