
This guide is for users who have data in a format such as SPSS or Stata and want to move that data into a SAS format. The guide will walk you through how to use StatTransfer to create both a SAS data file and a SAS catalog file to accompany the data file and provide value labels. Keep in mind when using this guide that SAS stores value labels in a file separate from the data file, in contrast to SPSS or Stata (where the value files are embedded in the data file).
(1). Click on the StatTransfer icon on the desktop or select the program from the Start Menu. For "Input File
Type", choose either SPSS or Stata, depending on whether it is an SPSS or Stata file you are trying to convert
into a SAS file (in this example, our original file is in SPSS. For "File Specification," type the file path
for the SPSS or Stata file or use the "Browse" button to the right to select the right directories and
filename.
Next, in the "Output File Type" box, select "SAS V8 for Windows/OS 2". StatTransfer will automatically fill in the
"File Specification" with the file path and file name for the new SAS data file. It will save it in the same
directory as the original SPSS or Stata file and use the same filename with a *.sas7bdat extension (which is the
extension for SAS data files in Windows).

Click here for full-size image
(2). Click on the "Options (1)" tab at the top of the StatTransfer window. In the box labeled "SAS Value
Labels" select "Write a Proc Format program." Fill in the text box with the location where the data file will
be saved and give the Proc Format program a name with a *.sas extension (the extension for SAS program files).
When this option has been selected, StatTransfer will create a SAS program that will produce a catalog file
consisting of value labels (in this example, StatTransfer will create a program file called "pf3966.sas" and save
it at C:\data\3966). SAS can then use this catalog file with the data file you create from SPSS or Stata.
This step is absolutely necessary if you want the value labels to carry over from SPSS or Stata to SAS

Click here for full-size image
(3). Click on the "Transfer" tab at the top of the StatTransfer window to return to the transfer dialog box
and click on the "Transfer" button. The SAS data file (e.g. da3966.sas7bdat) and program file (e.g. pf3966.sas)
should then appear in the directory specified in the "File Specification" box for the output file.

Click here for full-size image
(4). Now, the SAS program file must be modified so that SAS will create the catalog file with the value labels
and then attach those labels to variables in the data file. To do this, open the program file (the file with the
.sas extension) in SAS:

Click here for full-size image
(5). Where the program file reads libname library 'physical location' ; (libname library 'c:\data\3966' ;
in this example), choose a library name in which the data file and catalog file will be located:
Example: libname da3966 'c:\data\3966' ;
(Note - by default, StatTransfer writes the program file so that the directory where you saved the SAS data
file will be location to which the library you create will point.)
Next, following the "proc format library =" command, change "library" to the name of the library you created
above and follow the library name with the name you want to give to the catalog file that will be created and
stored in that library:
Example: proc format library = da3966.for3966 ;

Click here for full-size image
(6). Next, scroll down to the end of the "value" commands just before the proc datasets library =
library ; command line. Above this command you will add several new commands. First, add
options fmtsearch = (libraryname.formatfilename);
Example: options fmtsearch = (da3966.for3966);
This command tells SAS to look for a catalog file with a particular filename (for3966 in this example) in a
particular library (da3966 in this example).

Click here for full-size image
(7). Now, we need to add some commands to the program file that will
copy the SAS data file we created earlier back and forth from SAS's "Work"
library (SAS's temp library for short-term storage of files).
(a) To copy the data file into the "Work" library, add these commands:
proc datasets library=libraryname;
copy out = work; (SAS's temporary library)
select datafile;
run;
quit;
Example:
proc datasets library=da3966;
copy out = work;
select da3966;
run;
quit;
These commands will select the data file (e.g. da3966) from the specified
library (e.g. da3966) and copy it into the 'work' library.

Click here for full-size image
(b) Next, you will add commands to copy the data file from the 'work'
library back into the desired data library and overwrite the original
file. To do this, add these commands:
proc datasets library=work;
copy out = libraryname;
select datafile;
run;
quit;
Example:
proc datasets library=work;
copy out = da3966;
select da3966;
run;
quit;
These commands will copy a particular data file (e.g. da3966) from the "Work" library into another, specified
library (e.g. da3966).

Click here for full-size image
These steps are often necessary because SAS does not always like the SAS data files that StatTransfer creates
(you can read more here).
These commands do not fundamentally change any aspect of the data. They are often necessary, however, to ensure
that SAS and the data file produced by StatTransfer will be on speaking terms.
(8). Finally, in the proc datasets library = library ; command provided for you, change "library" to
your specified library name.
Example: proc datasets library = da3966 ;

Click here for full-size image
Save the file, then click on the Running Man
at the top or select 'Run' from the menu bar at the top and choose 'Submit'. The labels from the catalog file
should be successfully attached to the variables in the data file.
(9). In SAS' left window, click on the icon that looks like a file cabinet and is called "Libraries." Select
the library you created. Then click on the data file with the icon that looks like a spreadsheet. SAS will open
the data file in a spreadsheet, and the variable and value labels should be displayed.

Click here for full-size image