Stata Data Files

Details

Stata can read the following filetypes:

.dta - a data file in Stata format
.txt - data in ASCII (text) format
.raw - data in ASCII (text) format
.xls - a data file in Excel format

Different command statements are used to load data sets in different file formats. Most commonly you'll issue the use command to read Stata formatted data sets.

  • Click the File menu then click Open to open a data file already in Stata format.
  • use - opens a data file that is already in Stata format. The directory path must be specified i.e. use "c:\my documents\clients\hsb.dta"
  • use13 - opens a data file, which was created and saved in Stata 13; in Stata 12, i.e. ssc install use13 or use13 "mystatadataset.dta"
  • insheet - reads only comma or tab-delimited data; single line per observation; i.e. insheet id sex race ses sctyp hsp locus concept mot car rdg wrtg math sci civ using ":Macintosh HD:Desktop Folder:hsb2.raw"
  • infile - reads free field data and tab- or comma-delimited data; can have multiple records; i.e. infile id sex race ses sctyp hsp locus concept mot car rdg wrtg math sci civ using ":Macintosh HD:Desktop Folder:hsb1.raw"
  • infix - reads fixed field data; i.e. infix id 1-3 sex 4-8 race 9-13 ses 14-18 sctyp 19-23 hsp 24-28 locus 29-33 concept 34-38 mot 39-43 car 44-48 rdg 49-53 wrtg 54-58 math 59-63 sci 64-68 civ 69-73 using ":bananas:Users:ac:Desktop:hsb.txt"

You can cut and paste data from other applications into Stata's data editor.

Data sets in Stata follow the format where rows are cases/observations and columns are variables.

Support

For questions about using Stata not answered on this page, or for consulting requests regarding statistics, contact Jianjun Hua at 603-646-6552 or statistical.consulting@dartmouth.edu.

Details

Article ID: 64614
Created
Tue 10/9/18 12:17 PM
Modified
Mon 6/19/23 1:52 PM