Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: from stata to SAS


From   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: from stata to SAS
Date   Fri, 12 Jan 2007 08:33:26 -0600

Juzhi Wang <[email protected]> wrote, 

> [...] I need to import Stata data sets to SAS. What I need to do is to
> export the Stata into Excel and from Excel to SAS.

One easy way to export data from Stata to SAS is using Stata's -fdasave-
command, which will save the dataset in SAS XPORT format.  That will allow
you to skip the Excel step.  For example, 

        . use auto, clear 
          (1978 Automobile Data)


        . fdasave forsas
          the following variable(s) have names that must be changed to fit
          into .xpt format:  (suggested renamings shown):
 
                    displacement -> DISPLACE
                      gear_ratio -> GEAR_RAT
 
          specify option rename to save .xpt file with suggested names
        r(110);


        . fdasave forsas, rename
          the following variable(s) were renamed in the output file:
 
                    displacement -> DISPLACE
                      gear_ratio -> GEAR_RAT
 
          file forsas.xpt saved
          file formats.xpf saved

Another alternative, as Michael McCulloch <[email protected]> mentioned, is to use
Stat/Transfer, which will allow you to go directly to a SAS format dataset.
Stat/Transfer is available either from www.stattransfer.com or from
www.stata.com.

-- Bill
[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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index