Hello all, I have a situation in which I have a series of string variables that I want to use to compute a new series of numeric variables. The value labels are the same for each variable—and the reason I want to convert to numeric (while retaining the string) is to be able to create a multiple response variable. Here is a simple illustration of what I am looking for: Let’s say each case in my database can be associated with up to 40 different types of error codes, thus I have 40 error code variables: Error_1, Error_2…..through Error_40 and these are string variables Now I want to recode/compute into Error_1_Num, Error_2_Num through Error_40_Num without having to type out all 40 instances separately, how do I modify the code to loop through all 40 variables? Thanks, Sonya |
I may be wrong or misremembering but I think you could use Autorecode and I think there is a keyword to have the same numeric code for the same value label. So, 10 will have the same value label across the 40 variables. Gene Maguin From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Sidky, Sonya Y - DHS Hello all, I have a situation in which I have a series of string variables that I want to use to compute a new series of numeric variables. The value labels are the same for each variable—and the reason I want to convert to numeric (while retaining the string) is to be able to create a multiple response variable. Here is a simple illustration of what I am looking for: Let’s say each case in my database can be associated with up to 40 different types of error codes, thus I have 40 error code variables: Error_1, Error_2…..through Error_40 and these are string variables Now I want to recode/compute into Error_1_Num, Error_2_Num through Error_40_Num without having to type out all 40 instances separately, how do I modify the code to loop through all 40 variables? Thanks, Sonya |
In reply to this post by Sidky, Sonya Y - DHS
The easiest way would be to use AUTORECODE
with the /GROUP option and TO to define the input and output variable lists.
But note that multiple response variables can be constructed from strings if you use MRSETS and CTABLES. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: "Sidky, Sonya Y - DHS" <[hidden email]> To: [hidden email], Date: 07/01/2013 01:28 PM Subject: [SPSSX-L] recode multiple variables at one time Sent by: "SPSSX(r) Discussion" <[hidden email]> Hello all, I have a situation in which I have a series of string variables that I want to use to compute a new series of numeric variables. The value labels are the same for each variable—and the reason I want to convert to numeric (while retaining the string) is to be able to create a multiple response variable. Here is a simple illustration of what I am looking for: Let’s say each case in my database can be associated with up to 40 different types of error codes, thus I have 40 error code variables: Error_1, Error_2…..through Error_40 and these are string variables Now I want to recode/compute into Error_1_Num, Error_2_Num through Error_40_Num without having to type out all 40 instances separately, how do I modify the code to loop through all 40 variables? Thanks, Sonya |
Administrator
|
In reply to this post by Sidky, Sonya Y - DHS
At first, I thought you wanted AUTORECODE (with the GROUP subcommand). But now I'm not sure. A little more detail would be helpful. What are the possible values of Error_1 to Error_40, and what do you want the values of Error_1_Num to Error_40_Num to be? Are they indicators (i.e., 1=Yes, 0=No) for 40 possible errors?
And by the way, the new variables would be easier to work with (e.g., using the keyword TO) if you named them Error_Num_1 to Error_Num_40. 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/). |
In reply to this post by Jon K Peck
AUTORECODE/GROUP is certainly easy and obvious. And
putting the number at the end so you can say "A1 to A40" instead of typing a list is handy, too. On the other hand, going back to the question as stated -- There is no need to "loop through the variables" when using a simple RECODE. Give RECODE the list of variables to be recoded, the list of recodings, and (with INTO ) the list of new names. -- Rich Ulrich Date: Mon, 1 Jul 2013 13:37:50 -0600 From: [hidden email] Subject: Re: recode multiple variables at one time To: [hidden email] The easiest way would be to use AUTORECODE with the /GROUP option and TO to define the input and output variable lists. But note that multiple response variables can be constructed from strings if you use MRSETS and CTABLES. Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: "Sidky, Sonya Y - DHS" <[hidden email]> To: [hidden email], Date: 07/01/2013 01:28 PM Subject: [SPSSX-L] recode multiple variables at one time Sent by: "SPSSX(r) Discussion" <[hidden email]> Hello all, I have a situation in which I have a series of string variables that I want to use to compute a new series of numeric variables. The value labels are the same for each variable—and the reason I want to convert to numeric (while retaining the string) is to be able to create a multiple response variable. Here is a simple illustration of what I am looking for: Let’s say each case in my database can be associated with up to 40 different types of error codes, thus I have 40 error code variables: Error_1, Error_2…..through Error_40 and these are string variables Now I want to recode/compute into Error_1_Num, Error_2_Num through Error_40_Num without having to type out all 40 instances separately, how do I modify the code to loop through all 40 variables? Thanks, Sonya |
Administrator
|
I would only add: Use A01 TO A40
I will leave it for you to think about rather than be too obvious ;-) --
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 |