| File Format-Specific Reference for the IMPORT and EXPORT Procedures |
All versions of Stata under Microsoft Windows are supported. Stata files
have a .dta file extension.
See Example 1: EXPORT a SAS Data Set to a Stata DTA File
.
| FILES |
Import of all Stata versions under Microsoft Windows
and UNIX is 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 (a-z) or uppercase letter (A-Z), or an
underscore ( _ ). Subsequent characters can be any of these characters, plus
numerals (0-9). No other characters are permitted. Stata reserves these
19 words, which are not allowed to stand alone as variable names:
| _all |
long |
_N |
| in |
_skip |
_weight |
| _pred |
_cons |
float |
| _b |
_n |
pi |
| int |
using |
with |
| _rc |
double |
if |
| _coef |
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 (a-z)
or uppercase letter (A-Z), or an underscore ( _ ). Subsequent characters
can be any of these characters, plus numerals (0-9). 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 the FMTLIB=libref.format-catalog statement to save the
formats catalog in 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. |
| 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. |
This example exports the SAS
data set, SDF.CUSTOMER, to the Stata DTA
file, customer.dta, on a local system.
LIBNAME SDF V9 "&sasdir";
PROC EXPORT DATA=SDF.CUSTOMER
FILE="&tmpdir.customer.dta"
DBMS=STATA REPLACE;
RUN;
This example imports the SAS data set, WORK.CUSTOMER, from the Stata
DTA file, customer.dta, on a local system.
PROC IMPORT OUT=WORK.CUSTOMER
FILE="&tmpdir.customer.dta"
DBMS=STATA REPLACE;
RUN;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.