BookmarkSubscribeRSS Feed
Tithi
Calcite | Level 5

I am trying to convert my SAS file, which has over 2000 variables, into SPSS. However, when I open my SPSS file, I only see the labels being carried over, but my values are not. 

 

My formats and datasets are all in the "ab" library. 

 

This is the code I wrote: 

/*Create a dataset from a format catalog*/

proc format library=ab cntlout=ab.formats_data;
run;

 

/*Proc export the data*/

 

proc export data = ab.final_merged

outfile = "H:\dataset\final_merged.sav\";

DBMS= spss replace;

FMTLIB = ab.formats_data;

run;

 

Thank you! 

 

 

4 REPLIES 4
Tom
Super User Tom
Super User

PROC EXPORT needs the actual format catalog, not the dataset you generated with PROC FORMAT.

If the formats are not already on your FMTSEARCH path then add them to it.  The OUTFILE= option needs to point to a file and not a directory. Also the DBMS= and REPLACE options are part of the PROC EXPORT statement, not separate statements.   Hint:  When a statement uses more than one line place the semicolon that ends the statement at the beginning of its own line instead of hiding it at the end of line.

 

You don't NEED to make a CNTLOUT= dataset, but it is probably going to be  useful to share that also. And it could be useful if you cannot figure out how to modify the FMTSEARCH option since you can just have PROC FORMAT read it back in to re-create the formats in the WORK.FORMATS catalog.

/*Create a dataset that can define the format catalog*/
proc format library=ab.formats cntlout=ab.formats_data;
run;

/*  Re-create formats into WORK.FORMATS catalog */
proc format library=work cntlin=ab.formats_data;
run;

/*  Create SPSS save file */
proc export data = ab.final_merged
  outfile = "H:\dataset\final_merged.sav"
  DBMS= spss replace
;
run;

/* Create SPSS save file of the formats definition dataset */
proc export data = ab.formats_data
  outfile = "H:\dataset\formats_data.sav"
  DBMS= spss replace
;
run;
Tithi
Calcite | Level 5

Thanks for sharing your codes, I actually couldn't copy paste my earlier code but here is the accurate one. 

 

proc format library=ab cntlout=ab.formats_data;
run;


/*Step 2 : export to an .SAV file using the FMTLIB option in the PROC EXPORT procedure (using the formats data set)*/


PROC EXPORT DATA=ab.final_merged
OUTFILE="H:\Faculty_Projects\Abigail Batchelder\Datasets\final_merged2.sav"
DBMS=SPSS REPLACE;
FMTLIB=ab.formats_data;
RUN;

 

The codes you shared created the formats and the data files separately in SPSS; however, my original problem is still there. The formats carry only the labels but not all the values. 

Tithi
Calcite | Level 5
I figured it out, thank you!
Tom
Super User Tom
Super User

@Tithi wrote:

Thanks for sharing your codes, I actually couldn't copy paste my earlier code but here is the accurate one. 

 

proc format library=ab cntlout=ab.formats_data;
run;


/*Step 2 : export to an .SAV file using the FMTLIB option in the PROC EXPORT procedure (using the formats data set)*/


PROC EXPORT DATA=ab.final_merged
OUTFILE="H:\Faculty_Projects\Abigail Batchelder\Datasets\final_merged2.sav"
DBMS=SPSS REPLACE;
FMTLIB=ab.formats_data;
RUN;

 

The codes you shared created the formats and the data files separately in SPSS; however, my original problem is still there. The formats carry only the labels but not all the values. 


If you want to use the FMTLIB= statement in your PROC EXPORT you need to give it the name of the format CATALOG, not the name of DATASET.

So assuming your original PROC FORMAT statement that was using LIB=AB worked then you should be able to use either of these forms in your PROC EXPORT since the default catalog name PROC FORMAT would use when no name is provided is FORMATS.

fmtlib=ab;
fmtlib=ab.formats;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 344 views
  • 0 likes
  • 2 in conversation
OSZAR »