Import of all Stata
versions under Microsoft Windows and UNIX are supported. Export of
Stata version 8 and later is supported.
MISSING VALUES
Stata supports missing
values. SAS missing values are written as Stata missing values.
VARIABLE NAMES
When using importing,
Stata variable names can be up to 32 characters in length. The first
character in a variable name can be any lowercase letter or uppercase
letter or an underscore. Subsequent characters can be any of these
characters, plus numerals. No other characters are permitted. Stata
reserves the 19 words shown in the table below, which are not allowed
to stand alone as variable names:
Stata Reserved Words
_all
_n
in
using
_pred
double
_b
_N
int
_weight
_rc
float
_coef
pi
long
with
_skip
if
_cons
If the program encounters
any of these reserved words as variable names, it appends an underscore
to the variable name to distinguish it from the reserved word. For
example, _N becomes _N_.
When exporting, variable
names greater than 32 characters are truncated. The first character
in a variable name can be any lowercase letter or uppercase letter
or an underscore. Subsequent characters can be any of these characters
plus numerals. No other characters are permitted. Invalid characters
are converted to underscores.
VARIABLE LABELS
Stata supports variable
labels when using the IMPORT procedure. When exporting, if the variable
name is not a valid Stata name and there is no label, the EXPORT procedure
writes the variable name as the label.
VALUE LABELS
Stata stores value
labels within the data file. The value labels are converted to format
library entries as they are read with the IMPORT procedure. The name
of the format includes its associated variable name modified to meet
the requirements of format names. The name of the format is also associated
with a variable in the SAS data set. You can use FMTLIB= libref.format-catalog
statement to save the formats catalog under a specified SAS library.
When writing SAS data
to a Stata file, the EXPORT procedure saves the value labels that
are associated with the variables. The procedure uses the formats
that are associated with the variables to retrieve the value entries.
You can use the FMTLIB= libref.format-catalog statement to tell SAS
where to locate the formats catalog.
Note: Numeric formats only.
DATA TYPES
Stata supports numeric
field types that map directly to SAS numeric fields.
Stata date variables
become numerics with a date format.
When writing SAS data
to a Stata file, the EXPORT procedure converts data into variable
type double. A SAS date format becomes a Stata date variable.
Importing and Exporting Stata Data Files
Stata DTA Files (DBMS=STATA)
This IMPORT | EXPORT
method uses Stata DTA file formats to access data in Stata DTA files
on Linux, UNIX, and Microsoft Windows operating environments.
PC Files Server (DBMS=PCFS)
This IMPORT | EXPORT
method uses the client/server model to access data in Stata files
on Microsoft Windows from Linux, UNIX, or Microsoft Windows 64-bit
operating environments. This method requires running the PC Files
Server on Microsoft Windows.
Note: A filename with a .dta extension
is required.
Import and Export Procedures Supported Syntax
FMTLIB= libref.format-catalog.
When importing a Stata file, SAS saves value labels to the specified
SAS format catalog. When exporting a SAS data set to a Stata file,
SAS uses formats that are associated with the variables to retrieve
the value entries.
Example 1: Export a SAS Data Set to a Stata File on a Local
System
This example exports
the SAS data set SDF.CUSTOMER, to the Stata file, CUSTOMER.DTA, on
a local system.
Example 3: EXPORT a SAS Data Set on UNIX to a Stata File on
Microsoft Windows
This example exports
a SAS data set named SDF.CUSTOMER to a Stata file named CUSTOMER.DTA.
Note that SAS is running on the UNIX operating platform. The Stata
file is loaded on Microsoft Windows where PC Files Server is running.
Example 4: Import Data from a Stata File on Microsoft Windows
to a SAS Data Set on UNIX
This example imports
data from a Stata file named CUSTOMER.DTA to a SAS data set named
WORK.CUSTOMER. Note that SAS is running on a UNIX platform. The Stata
file is located on Microsoft Windows where PC Files Server is running.