Automatic recode string-numeric

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Guest

Automatic recode string-numeric

Postby Guest » Tue Jun 12, 2007 10:35 am

Hi!

I've a doubt regarding recoding string variables into numeric.

I know that when I import a database from Excel or Acess (using New Query), and some of the variables are coded as string, SPSS as an automatic option to recode string to numeric, and also including the labels. This is very useful way when I get some databases with a lot of string variables.

But I recently received a database that's already in SPSS format with hundreds of string variables. What I wanted to know if there's a way to automatic recode/transform string variables into numeric and also make the labels automatically (like the way when we import databases from other formats), without using the new query solution.


Thank you!
cantara
Posts: 17
Joined: Tue Jun 12, 2007 10:21 am

Postby cantara » Tue Jun 12, 2007 10:46 am

I'm sorry, but this post was made with guest. It was me who made this one! :wink:
cantara
Posts: 17
Joined: Tue Jun 12, 2007 10:21 am

Postby cantara » Tue Jun 12, 2007 11:03 am

Ok, please delete this dumb question! It's only a matter of Automatic Recode... :oops:
forum
Site Admin
Posts: 14
Joined: Tue Apr 10, 2007 8:17 am

Postby forum » Tue Jun 12, 2007 12:29 pm

Cantara, no problem! Maybe you could explain how you use Automatic Recode to achieve what you want?
statman
Administrator
Posts: 2721
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA

Postby statman » Tue Jun 12, 2007 12:34 pm

cantara, the only dumb question is the one not asked.

When you post it would be helpful to ID the version of SPSS you are using since that can greatly affect the response.

There isn't an autorecode that also gives the labels but beginning with, around V12 or 13 an autorecode freature was added under Transform but not sure will get you where you want to be. "Play" around with the following syntax to see if it helps, you still need to add the labels.
DATA LIST LIST /Q1(A7), Q2(A7), Q3(A7).
BEGIN DATA
1234567 1234567 1234567
1234567 1234567 1234567
1234567 1234567 1234567
1234567 1234567 1234567
END DATA.
LIST.

rename vars (q1 to q3 = s1 to s3).
numeric q1 to q3(f7).
do repeat s=s1 to s3 / q=q1 to q3.
compute q = numeric(s,f7).
end repeat.
list.

numeric x1 to x3 (f7).
recode s1 to s3 (convert) into x1 to x3.
list.
See the note below

NOTE: Please read the Posting Guidelines and always tell us your OS, the SPSS version and information about your study and data!

Statman
Statistical Services
cantara
Posts: 17
Joined: Tue Jun 12, 2007 10:21 am

Postby cantara » Thu Jun 14, 2007 6:45 pm

Hi!

thanks for the feedback!
Recently I changed to version 15, because my university has a new license, and therefore made the upgrade.

Regarding to the thread, I used the Automatic Recode function, under Transform. You can recode the variable in alphabetically ascending or descending way. It was very useful because, as I said before, I had a lot of string variable that needed recode to numeric, to make some hypothesis tests and regression models.

And thanks for the syntax output. It will go to my syntax collection! You'll never know when you'll need it! :P
statman
Administrator
Posts: 2721
Joined: Tue Jun 12, 2007 12:08 pm
Location: Florida, USA

Postby statman » Thu Jun 14, 2007 7:41 pm

So I guess you are OK and the topic can be closed? If so please reply accordingly.
See the note below

NOTE: Please read the Posting Guidelines and always tell us your OS, the SPSS version and information about your study and data!

Statman
Statistical Services
cantara
Posts: 17
Joined: Tue Jun 12, 2007 10:21 am

Postby cantara » Tue Jun 19, 2007 9:37 am

Sure! You can close it.

Who is online

Users browsing this forum: No registered users and 1 guest

cron