Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Reading ASCII data [U] 24<br />
Reading tab- or comma-separated data [R] insheet<br />
In tab-separated data the tabula<strong>to</strong>r character, here displayed as , separates the values. A<br />
tab-separated ASCII file is created e.g. if you save an Excel worksheet as a text (.txt) file. If<br />
row 1 is variable names, <strong>Stata</strong> will find out and use them. In this and the following examples<br />
the value of type in observation 2 is missing.<br />
id type sold price<br />
1 2 47 51.23<br />
2 793 199.70<br />
You may read a tab-separated ASCII file with variable names in row 1 by the command:<br />
insheet using c:\dokumenter\p1\a.txt , tab<br />
In comma-separated data a comma separates each value:<br />
1, 2, 47, 51.23<br />
2, , 793, 199.70<br />
If you have a comma-separated file without variable names in row 1 the command is:<br />
insheet id type sold price using c:\dokumenter\p1\a.txt , comma<br />
insheet assumes that all data belonging <strong>to</strong> one observation are in one line.<br />
Reading freefield data [R] infile (free format)<br />
In freefield data commas or blanks separate each value:<br />
1 2 47 51.23<br />
2 . 793 199.70<br />
If you have freefield data the command is<br />
infile id type sold price using c:\dokumenter\p1\a.txt<br />
infile does not assume that data belonging <strong>to</strong> one observation are in one line, and the<br />
following data are the same as the data above:<br />
1 2 47 51.23 2 . 793 199.70<br />
Reading fixed format data [R] infix; [R] infile (fixed format)<br />
In fixed format data the information on each variable is determined by the position in the line.<br />
The blank type in observation 2 will be read as missing.<br />
1 2 47 51.23<br />
2 793 199.70<br />
infix id 1 type 2-3 sold 4-7 price 8-14 using c:\dokumenter\p1\a.txt<br />
Fixed format data can also be read by infile; <strong>to</strong> do this a dictionary file must be created,<br />
specifying variable names and positions etc. See [R] infile (fixed format).<br />
17