|
Hello all I am working with SPSS to recode some data before
undertaking statistical analysis. My problem is knowing the best/simplest
way to recode my data. The current data is categorical,
with multiple response options, as shown below. I would like to recode
the data to create a new dummy-coded variable for each response option.
I know that I can do this manually, by specifying an IF
statement for each option, but I have many variables to recode. I am
therefore wondering if anyone could help me with my syntax. I have used Do Repeat before, and have been happy with the
results, but I am not sure that this can be used to create several new
variables from each existing variable. I am sure that this can be easily done via a macro, but I
have not yet mastered the art of writing SPSS macros myself! Any
help/pointers would therefore be greatly appreciated. Cheers Tim Timothy
Johnson | Marketing Sciences Methodologist | Harris Interactive |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Administrator
|
You could use DO-REPEAT. E.g., numeric newvar1 to newvar8 (f1.0). do repeat v = newvar1 to newvar8 / #i = 1 to 8 . - compute v = (oldvar EQ #i). end repeat. exe. Alternatively, you could use VECTOR & LOOP: numeric newvar1 to newvar8 (f1.0). vector v = newvar1 to newvar8 . loop #i = 1 to 8. - compute v(#i) = (oldvar EQ #i). end loop. exe.
--
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 tjohnson
Hi Timothy,
The basic codes for (un)dummifying are *Testdata, single 5-point Likert. data list free/v1. begin data 1 2 3 4 5 end data. *Dummify. do rep a=v_1 to v_5/b=1 to 5. comp a=v1=b. end rep. exe. *Undummify. do rep a=v_1 to v_5/b=1 to 5. if a=1 v2=b. end rep. exe. HTH! Ruben van den Berg Methodologist TNS NIPO P: +31 20 522 5738 Date: Mon, 18 Jan 2010 17:32:25 +0000 From: [hidden email] Subject: Creating several dummy-coded variables from a single categorical variable To: [hidden email] Hello all
I am working with SPSS to recode some data before undertaking statistical analysis. My problem is knowing the best/simplest way to recode my data.
The current data is categorical, with multiple response options, as shown below. I would like to recode the data to create a new dummy-coded variable for each response option.
I know that I can do this manually, by specifying an IF statement for each option, but I have many variables to recode. I am therefore wondering if anyone could help me with my syntax.
I have used Do Repeat before, and have been happy with the results, but I am not sure that this can be used to create several new variables from each existing variable.
I am sure that this can be easily done via a macro, but I have not yet mastered the art of writing SPSS macros myself! Any help/pointers would therefore be greatly appreciated.
Cheers Tim
Timothy
Johnson | Marketing Sciences Methodologist | Harris Interactive Express yourself instantly with MSN Messenger! MSN Messenger |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The recoding part of this problem could also be solved in a more general way with the SPSSINC CREATE DUMMIES extension command available from SPSS Developer Central (www.spss.com/devcentral). That command, which requires the programmability plugin, discovers the values for a (categorical) variable and generates a set of dummy variables for them using a user-specified rootname. Regards, Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
Hi Timothy, The basic codes for (un)dummifying are *Testdata, single 5-point Likert. data list free/v1. begin data 1 2 3 4 5 end data. *Dummify. do rep a=v_1 to v_5/b=1 to 5. comp a=v1=b. end rep. exe. *Undummify. do rep a=v_1 to v_5/b=1 to 5. if a=1 v2=b. end rep. exe. HTH! Ruben van den Berg Methodologist TNS NIPO E: ruben_van_den_berg@... P: +31 20 522 5738 I: www.tns-nipo.com
Date: Mon, 18 Jan 2010 17:32:25 +0000 From: [hidden email] Subject: Creating several dummy-coded variables from a single categorical variable To: [hidden email] Hello all I am working with SPSS to recode some data before undertaking statistical analysis. My problem is knowing the best/simplest way to recode my data. The current data is categorical, with multiple response options, as shown below. I would like to recode the data to create a new dummy-coded variable for each response option.
I know that I can do this manually, by specifying an IF statement for each option, but I have many variables to recode. I am therefore wondering if anyone could help me with my syntax. I have used Do Repeat before, and have been happy with the results, but I am not sure that this can be used to create several new variables from each existing variable. I am sure that this can be easily done via a macro, but I have not yet mastered the art of writing SPSS macros myself! Any help/pointers would therefore be greatly appreciated. Cheers Tim Timothy Johnson | Marketing Sciences Methodologist | Harris Interactive +44 (0)208 263 5271 | tjohnson@...
Express yourself instantly with MSN Messenger! MSN Messenger
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Free forum by Nabble | Edit this page |
