|
We use SPSS Version
14. Can anyone tell me if there is syntax that allows you to test if a variable
is STRING or NUMERIC type ?
|
|
Also something like this syntax should work. DISPLAY VARIABLES /VARIABLES = VARA VARB . Art Kendall Social Research Consultants On 10/14/2010 12:10 PM, Krampner, John 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 REFCARD
Art Kendall
Social Research Consultants |
|
Guessing that you have a variable list that might have some variables that are strings. In which situation all results In some circumstances something like this untested syntax might work. do repeat myvar = vara to vare/ somevar = newvar1 to newvar5. compute isstring=0. do if sysmis(myvar/1) . compute isstring = 1. compute somevar = -999. else. compute somevar = ... end if. end repeat missing values newvar1 to newvar5 (lo thru -1). add value labels newvar1 to newvar5 -999 ' oops! a string!'. Art Kendall Social Research Consultants On 10/14/2010 1:12 PM, Krampner, John 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 REFCARD
Art Kendall
Social Research Consultants |
|
open a new instance of SPSS. Copy the syntax below into s syntax
window. Run the syntax. Is this what you want to do?
This syntax will generate a lot of errors. But notice that it gives the results you want. You can uncomment the SET command when you see what it does. new file. *set errors=no. data list list/id (f2), v1 (f1) v2(a1), v3(f1) v4 (a1). begin data 01 1 '4' 1 '4' 02 2 '5' 2 '5' 03 3 '6' 3 '6' end data. numeric new1 to new4 (f1). do repeat old = v1 to v4 /new= new1 to new4. do if (old/1.0.) eq $sysmis. recode old(convert) into new. ELSE. recode old(else=copy) into new. end if. end repeat. list. Art Kendall Social Research Consultants On 10/14/2010 2:01 PM, Krampner, John 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 REFCARD
Art Kendall
Social Research Consultants |
|
In reply to this post by Krampner, John
Is this before or after you have a data
editor? If after, the types are listed in variable view: if before it's
string if it has any characters other than numbers in it. You need to post
more details , including sample data, if you want a proper answer.
|
|
Administrator
|
Hi John. You may have missed that the OP clarified what he was after in a private reply to Art. I.e., On 10/14/2010 2:01 PM, Krampner, John wrote: > Thanks again. What I am trying to do is run a RECODE VARA (CONVERT) INTO VARB on a number of variables if, and only if, the variable is a string. This never appeared on the mailing list directly, as far as I know. I saw it in Art's reply to the list, which included a very nice solution to the problem. HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
| Free forum by Nabble | Edit this page |
