Noob_Strider
Noob_Strider

Reputation: 183

Import SPSS data into SAS without Labels and Values

As I am new to SAS I am having trouble to import spss data into sas using the "proc import" command. The code I was using:

proc import datafile = "C:\Users\spss.sav"
 out=work.test
 dbms = sav
 replace;
 run;

The main problem is that when imported to sas, the datatable variables have the values and not the coding. So for instance if the variable "Gender" is coded 1=male 2=female, each observation in sas has "female" or "male".

Now according to here:

Proc Import from SPSS

if the following code is added after the code above, then this problem ceases to exist:

proc datasets;
modify my_dataset;
format _all_;
quit;

What still remains is that the Variable names from spss, instead of having their name, when imported to sas they have the labels that are assigned in spss. Is there any command that can keep the Names of the variables in SAS, instead of the SPSS labels?

Upvotes: 2

Views: 1999

Answers (2)

Wes McClintick
Wes McClintick

Reputation: 507

I had a similar problem. I had yearly SPSS datasets for a survey and the same format, call it "Yearformat" would go 0=2011, 1=2012, ... for the 2011 data, but 0=2012, 1=2013, ..., for 2012 data, etc. It seems like there should be a better solution, but what I did was .. SPSS -> save as SAS 9 for windows.. and click the option to output the formats to a sas dataset and then applied / modified the formats as necessary along the way .. mainly data datacopy ; set data ; newyear = put(year,yearformat.) to preserve the proper years.

enter image description here

But the point is, SPSS will create a sas dataset without the formats and a script with the formats and code to apply/modify the dataset with those formats. So you have control over the process.

Upvotes: 0

SRSwift
SRSwift

Reputation: 1710

It's possible that you are seeing column labels but that the underlying names still exist. You can modify your datasets procedure to remove the labels as well as the formats. Try this after your proc import:

proc datasets library = work;
    modify test;
    attrib _ALL_ label = " " format =;
run;

The attrib statement is applying a blank label and format to every variable.

Upvotes: 3

Related Questions