Help using Base SAS procedures

Proc import spss without lables/formats

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Proc import spss without lables/formats

Hi

Is it possible to import a *.sav file into SAS without also getting labels/formats that is defined in SPSS?

Thanks in advance,

Kristoffer


Accepted Solutions
Solution
‎01-09-2012 10:44 PM
Super User
Posts: 10,023

Proc import spss without lables/formats

I don't know how to use proc import to eliminate labels and format.

But you can erase them after importing SAS.

data class;
 set sashelp.class;
 label sex='gender';
 format weight dollar12.;
run;

proc datasets library=work nolist;
modify class;
 attrib _all_ label=' ' format=;
quit;



Ksharp

View solution in original post


All Replies
Solution
‎01-09-2012 10:44 PM
Super User
Posts: 10,023

Proc import spss without lables/formats

I don't know how to use proc import to eliminate labels and format.

But you can erase them after importing SAS.

data class;
 set sashelp.class;
 label sex='gender';
 format weight dollar12.;
run;

proc datasets library=work nolist;
modify class;
 attrib _all_ label=' ' format=;
quit;



Ksharp

Occasional Contributor
Posts: 6

Proc import spss without lables/formats

Thanks for your help. Thats convenient enough. Cheers

Contributor
Posts: 41

Re: Proc import spss without lables/formats

Does anyone know how to keep the SPSS formats after importing the SPSS .sav file and then storing as SAS dataset in a permanent library? In other words, after saving as a SAS dataset I can not open the file unless I remove all the labels and formats the code mentioned in this post.

Super User
Posts: 11,343

Re: Proc import spss without lables/formats

If you are getting an error related to unavailable formats try

options nofmterr;

the SAS option FMTERR / NOFMTERR determines whether an undefined format is an error or not. If the FMTERR is set then you can't open data sets that have such formats (or run PROC FREQ  or do much of anything else.)

Contributor
Posts: 41

Re: Proc import spss without lables/formats

Thanks. This auto copied the formats folder to the permanent library but still getting "ERROR: can open the table DS.dataset. I am using SAS 9.2 x64 on MS 2003 Terminal Server. Also, this only occurs if I close the SAS program I used to import the SPSS file and then open a different SAS file.

Super User
Posts: 10,023

Re: Proc import spss without lables/formats

Check it out.

Contributor
Posts: 41

Re: Proc import spss without lables/formats

Thanks. This is difinitely useful info. So you can't import a SPSS file with formats and labels and then create a SAS dataset with these formats and labels very easily? My goal is to keep the dataset with formats and labels associated with the original SPSS file as a SAS dataset. I usually don't have issues with giving SPSS users SAS datasets because SPSS doesn't have problems importing SAS datasets.

Super User
Super User
Posts: 7,039

Re: Proc import spss without lables/formats

In SPSS the formats (?data labels?) are stored in the same file as the data.  In SAS only the NAME of the format is stored with the data.  So you will need to add additional steps to both save the formats where you want them and for the users to use to make sure they can find the formats when they use the data.

You could instead generate code to save the formatted values as new variables in the data.

proc sql noprint ;

  select name,cats(name,'_decode')

  into :name separated by ' '

     , :decode separated by ' '

  from dictionary.columns

  where libname='SASHELP'

   and  memname='CLASS'

  ;

quit;

data new;

  set sashelp.class;

  array _decode $200 &decode ;

  do _n_=1 to dim(_decode);

    _decode(_n_)=vvaluex(scan("&name",_n_,' '));

  end;

run;

Super User
Posts: 10,023

Re: Proc import spss without lables/formats

I search it at this site. You can find a lot of resource about it.

https://communities.sas.com/message/7278#7278

http://www.psych.yorku.ca/lab/sas/spss2sas.htm

Ksharp

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 2380 views
  • 4 likes
  • 5 in conversation