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:
Thank you.
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.
@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.
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.
@Tom Okay. Thanks a lot for your assistance.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.