BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have converted the SPSS dataset into SAS dataset. However, the variable and value labels developed in SPSS could not be read in SAS. Please advise me how to maintain the conversion labels. Thank you.
9 REPLIES 9
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Recommend you search the SAS support website http://support.sas.com -- there are DOC references on the topic with useful information on your query/post. In particular, the SAS system/architecture has "SAS variable labels" but SAS does not have a concept for "value labels", as I understand from reading support reference material found with a search.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

spss label sas conversion site:sas.com
Ksharp
Super User
I am not test it.
Try to use :

[pre]
options label;
[/pre]



or use proc report to test is.(I am not sure.)


Ksharp
Reeza
Super User
How are you importing/exporting between packages?

I recently found for me that if I export the SPSS data to SAS, from SPSS then I lose my labels and formats. In my export there's also an option to save the formats to a file. This is converting a .sav file to .sas7bdat

If I read the SPSS .sav file from SAS then it reads the formats/labels.

I'm using SAS 9.2 and SPSS 14.
ballardw
Super User
It has been awhile since I used SPSS but the option to export to SAS had a check box to export the formats and labels. This generated separate SAS code files with PROC FORMAT and LABEL statement syntax.

If you didn't check the box no joy for labels or fromats.
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you @Reeza for sharing your approach. I want to use your method to read an SPSS dataset into SAS and bring with it the value and variable labels (It looks like when I export from SPSS to SAS, I can only bring the value labels and not the variable labels).

1- May you please edit my code to include the value and variable labels?

2- Also, how may I restrict my SAS data to a subsample. for example, WHERE agegroup = 2;  

 

PROC IMPORT
DATAFILE= "C:\SPSSdata.sav"
OUT=SASdata
DBMS=sav REPLACE;
RUN;

 

Thanks

Reeza
Super User

@Emma_at_SAS unfortunately I no longer have SPSS to test anything out. 

 

For filtering that's fairly easy.

 

You've named your output data SASdata and can use a WHERE statement to filter it. See two examples below, one to create a new data set and one to filter a data set in a procedure. 

data sasData_Group2;
set SASdata;
where agegroup=2;
run;

proc means data=sasdata;
where agegroup=2;
run;
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you @Reeza for your response. I was wondering how to use a WHERE statement in the PROC IMPORT to only import part of a dataset. Maybe that will reduce the time to read a subsample from a larger dataset. Thanks 

 

Reeza
Super User
Most likely not reduce the time but you can try.



PROC IMPORT
DATAFILE= "C:\SPSSdata.sav"
OUT=SASdata (where=(agegroup=2))
DBMS=sav REPLACE;
RUN;

Emma_at_SAS
Lapis Lazuli | Level 10

Thank you for your suggestion @Reeza 

I will try it. the WHERE statement does not turn blue and my SPSS data is password protected. I cannot check this code now but will check it later. Thanks  

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2747 views
  • 0 likes
  • 6 in conversation