BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
smygarn
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

9 REPLIES 9
Ksharp
Super User

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

smygarn
Calcite | Level 5

Thanks for your help. Thats convenient enough. Cheers

WAL83
Obsidian | Level 7

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.

ballardw
Super User

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.)

WAL83
Obsidian | Level 7

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.

Ksharp
Super User

Check it out.

WAL83
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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