0
votes

I have a simple data table in SAS, where I have the results from a survey I sent to my friends:

DATA Questionnaire;
  INPUT make $  Question_Score ;
CARDS;
Ned 1
Shadowmoon  2
Heisenberg  1
Athelstan   4
Arnold  5
;
RUN;

What I want to do, using SAS, is to export this table into SPSS (.sav), and also have the value labels for the Question_Score, like shown in the picture below:

enter image description here

I then proceed to create a format in SAS (in hope this would do it):

PROC FORMAT;
  VALUE  Question_Score_frmt 
                1="Totally Agree"
                2="Agree" 
                3="Neutral" 
                4="Disagree" 
                5="Totally Disagree" 
;
run;


PROC FREQ DATA=Questionnaire;
   FORMAT  Question_Score Question_Score_frmt.
;
TABLES Question_Score;
RUN;

and finally export the table to a .sav file using the fmtlib option:

proc export data=Questionnaire outfile="D:\Questionnaire.sav"
dbms=spss replace;
fmtlib=work.Q1frmt;
quit;

Only to disappoint myself seeing that it didn't work.

Any ideas on how to do this?

1

1 Answers

0
votes

You didn't apply the format to the dataset, unfortunately, you applied it to the proc freq. You would need to use PROC DATASETS or a data step to apply it to the dataset.

proc datasets lib=work;
  modify questionnaire;
  format Question_Score Question_Score_frmt.;
run;
quit;

Then exporting will include the format, if it's compatible in SAS's opinion with SPSS's value label rules. I will note that SAS's understanding of SPSS's rules is quite old, based on I think SPSS version 9, and so it's fairly often that it won't work still, unfortunately.