BookmarkSubscribeRSS Feed
adenirane
Calcite | Level 5

Hello everyone,

I am a new SAS user and recently I tried importing an SPSS data into SAS. Although import was successful, all the variables read as numeric (including character variables). I have about 73 variables (constituting of character and numeric). I need help correcting this before I go-ahead to do the analysis. I am afraid if I go ahead without fixing this (variable types), that my analysis will be affected. Please note I am using the SAS University edition for my analysis. Kindly help.

 

Here is my code:

 

Libname Tutorial '/folders/myfolders/';
*Importing SAS file;
proc import datafile = '/folders/myshortcuts/Myfolders/TBR_NMUS_1_copy.sav'
out=tutorial.intern
dbms=SAV 
replace;
run;
proc contents data= tutorial.intern;
run;

 

This is some part of the data results:

Capture25.PNG

 

Thank you.

4 REPLIES 4
Tom
Super User Tom
Super User

Looks like your SPSS variables were using numeric codes.  That is why the import step made them as numeric.  Notice how it made the user defined formats like Q2A and Q8A listed in your PROC CONTENTS display.  That way the numeric codes will print with the proper decoded text strings.  Make sure to tell PROC IMPORT where you want it to write the formats it creates.  By default it writes to WORK.FORMATS catalog and that will disappear at the end of your current SAS session.  Also watch out for format name collision if you read in multiple SPSS datafiles that use the same variable names with different coding.

adenirane
Calcite | Level 5

@Tom  Thanks very much for your feedback. I noticed when I used proc print, the decoded text strings were read properly (just as you said). However, my concern is that if I go on to do analysis will the analysis be done properly? Also, how can I inform proc import on where to write the formats it creates? 

I was just hoping I could fix the variable type so as to be on a safer side. Thanks for your help.

Tom
Super User Tom
Super User

It shouldn't matter in your analysis. Most analysis procedures will let you use a CLASS statement to let it know that your variable is categorical and not a continuous number.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 521 views
  • 0 likes
  • 2 in conversation