Thanks to Kit Baum, the SAS macro savastata on SSC has been updated.
I fixed a bug with numeric variables that had both positive and negative
formatted values and made a few tweaks, one of which is that the raw
ascii datafile in the SAS work directory is now deleted when -savastata-
successfully completes. This helps when processing many files in one SAS session.
None of these fixes had to do with data integrity.
The savastata program is run by the SAS system to write out your SAS dataset
to a raw ascii datafile, and write a Stata input program to read in the
dataset as well as preserve user-defined formats as value labels. Variable
labels are also preserved. The resulting Stata datafile is created in
a "compressed" state, variables that can be stored as variable type byte are
stored as that or whatever minimum storage type is required to store
your data accurately as a Stata datafile. The savastata macro then calls Stata
to read in the file and save it as a Stata datafile.
The savastata macro is also used with the Stata command -usesas- that reads
into Stata any SAS datafile type or SPSS portable file (*.por).
The complimentary program to -savastata- and -usesas- is the Stata command -savasas-
which saves Stata datasets as SAS datasets.
Type:
. ssc describe usesas
to learn more about both -savastata- and -usesas-.
Type:
. ssc describe savasas
to learn more about both -savasas-
For you Unix/Linux users who have both SAS and Stata, the c-shell script -savas-
uses both -savastata- and -savasas- to make a Stata copy of your SAS dataset or a
SAS copy of your Stata dataset. The savas script is also available on the SSC.
All programs are also available at:
http://www.cpc.unc.edu/services/computer/presentations/sas_to_stata/
Dan Blanchette
Applications Analyst Programmer
Carolina Population Center UNC-CH
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/