12.07.2015 Views

Stata Tutorial - Data and Statistical Services - Princeton University

Stata Tutorial - Data and Statistical Services - Princeton University

Stata Tutorial - Data and Statistical Services - Princeton University

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1.3. About <strong>Data</strong> for <strong>Stata</strong>To put a data set into <strong>Stata</strong>’s memory, the data set has to be in a format <strong>Stata</strong> underst<strong>and</strong>s. The following is a list of theextensions of files <strong>Stata</strong> can read directly.<strong>Data</strong> Format File Extension Comm<strong>and</strong> to read the data<strong>Stata</strong> .dta . useText (ASCII)Free or fixed columns .raw, .txt . infile usingComma separated values .csv . insheet usingFixed columns .dat . infix usingSAS export .xport, xpt . fdauseMS Access .mdb . odbcMany data download sites provide you with data already formatted for a common statistical program such as <strong>Stata</strong>, SPSS, orSAS. Formatted data often contain variable labels <strong>and</strong> value labels, that make it easier for you to underst<strong>and</strong> the contents of thedata.If <strong>Stata</strong> data are not available, <strong>and</strong> you can choose a data format between SPSS <strong>and</strong> SAS, then I would recommend selectingSPSS. You can use SPSS to open SPSS data, then save the data as <strong>Stata</strong> data. SPSS versions 12 <strong>and</strong> up can save the data as<strong>Stata</strong> 8 data 1 . Windows version of SPSS is available in McCosh 59 cluster or DSS computer lab. If data are only available inSAS format, you may use SAS to open SAS data, then create SAS export file, as <strong>Stata</strong> can read a SAS export file. Windowsversion of SAS is available in DSS computer lab. Unix version of SPSS <strong>and</strong> SAS are available at tombstone.Also, if you acquire data that are in a format other than <strong>Stata</strong>, you may use DBMS/Copy to convert them into <strong>Stata</strong> format.Windows version of DBMS/Copy is available in DSS computer lab. Unix version of DBMS/Copy is available at Tombstone.If you have SAS data, we recommend converting them into SAS transport file in SAS instead of using DBMS/Copy.DBMS/Copy has a known issue in converting value labels from SAS to <strong>Stata</strong>.If formatted data are not available, data distributers may provide set up files in <strong>Stata</strong>, SPSS, or SAS along with ASCII data.ASCII data set is a text file with rows (or columns) of numbers. If a set up file is available in <strong>Stata</strong>, you can attach the variableinformation using <strong>Stata</strong>. If a set up file is available in SPSS, it will be easier to use SPSS to attach the definition, then save thedata as <strong>Stata</strong> data. If a set up file is available in SAS, you may use SAS to attach the file definition, then create a SAS export filein SAS. You may also modify the set up files in text editors to use in <strong>Stata</strong>. Comm<strong>and</strong>s to define data are different in all threeprograms. If no set up files are available <strong>and</strong> only PDF codebooks are available, you will need to select the variables you wantto use <strong>and</strong> create your own set up file for <strong>Stata</strong>.If you need help in defining or converting data, please come by the <strong>Data</strong> <strong>and</strong> <strong>Statistical</strong> <strong>Services</strong> computer lab at A-16-H-3 inFirestone Library during walk-in hours or email data@princeton.edu. The hours <strong>and</strong> directions are available athttp://dss.princeton.edu. If you are emailing questions, please use your <strong>Princeton</strong> email. Our resources <strong>and</strong> assistance areavailable to <strong>Princeton</strong> <strong>University</strong> community members.<strong>Stata</strong> data format has changed from version 9 to version 10. <strong>Stata</strong> 10 can read data saved for <strong>Stata</strong> 9, but <strong>Stata</strong> 9 can not readdata saved for <strong>Stata</strong> 10, while both has the same extension .dta. If you plan to use <strong>Stata</strong> 9 after using <strong>Stata</strong> 10, you may save thedata as <strong>Stata</strong> 9 data in <strong>Stata</strong> 10. Followinig comm<strong>and</strong>s allow you to save data as <strong>Stata</strong> 9 data in <strong>Stata</strong> 10.CMD: . saveold filenameMNU: File=> Save As. Then select “<strong>Stata</strong> 9 <strong>Data</strong>” from the drop down list for box “Save As Type:”1 <strong>Stata</strong> 8 <strong>and</strong> <strong>Stata</strong> 9 data are interchangeable.Page 5 of 28

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!