|
|
|
||||
|
|
|||||
You can use Stat/Transfer to copy SAS files (with formats) into Stata data (.dta) files. It requires a small amount of extra work to do this, as described below.
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:\carsdata\auto.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:\carsdata\auto.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.
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services