You can use Stat/Transfer to copy SAS files (with formats) into SPSS (.sav) files. It requires a small amount of extra work to do this, as described below.
Step 1. Make a copy of your format library as a regular SAS data file
Say that you have a SAS data file on your PC in a directory called c:carsdata and and your data file and format library are both located in that directory. Suppose that the file is called auto.sd2 and your permanent format library is called formats.sc2 (the format library is always called formats.sc2). Stat/Transfer does not understand how to read the formats.sc2 file, but SAS can create a regular data file that Stat/Transfer can understand. The sample program below shows how to do this. In this program, only change the directory (i.e. c:carsdata ) to be the directory where your format file is located.
LIBNAME LIBRARY "c:carsdata" ;
PROC FORMAT LIBRARY=LIBRARY CNTLOUT=LIBRARY.SAS_FMTS ; RUN;
When you have run the above program, it will create a file called sas_fmts.sd2 in the c:carsdata directory. Stat/Transfer can read this file to convert your formats from SAS to Stata, so now, you are ready to transfer your SAS data file and formats to Stata using Stat/Transfer.
Step 2. Copy the file using Stat/Transfer
Start up Stat/Transfer. As you see below, on the first screen we picked SAS For Windows/OS2 as the input file type, and c:carsdataauto.sd2 as the file to transfer. For the output file we have chosen Stata Version 6 and we accepted the default name for the output file, c:carsdataauto.dta.
Once you have filled out the screen above, click the Options(1) tab and you will see a screen like the one below. Check the box labeled Read user formats from a SAS datafile.
Now, click the Transfer tab to return to the transfer screen, and on then click the box labeled Transfer to execute the transfer. In our example, this creates a file called auto.dta that has Stata formats associated with the variables.
Web notes
- See How do I convert a SAS file to Stata? for more general information on converting SAS files to Stata.
- See the Stata Frequently Asked Questions titled How do I convert Stata files with value labels to become SAS files with formats? for information about transferring files back from Stata to SAS.