|
|
|
||||
|
Help the Stat Consulting Group by
giving a gift
| |||||
|
Loading
|
|||||
You can read this kind of file using the insheet command as shown below.make,mpg,weight,price AMC Concord,22,2930,4099 AMC Pacer,17,3350,4749 AMC Spirit,22,2640,3799 Buick Century,20,3250,4816 Buick Electra,15,4080,7827
We can issue the list command to see if the data was read properly.insheet using comma.txt
list
make mpg weight price
1. AMC Concord 22 2930 4099
2. AMC Pacer 17 3350 4749
3. AMC Spirit 22 2640 3799
4. Buick Century 20 3250 4816
5. Buick Electra 15 4080 7827
As you can see, the insheet command was pretty smart. It got the variable names
from the first row of the data. It looks at the first row and can get the
variable names from the first row. It also examines the file and
determines for itself whether the data are separated by commas or by
tabs. The exact same command could read the same file but delimited with tabs (you
can try reading tab.txt for
yourself). If you would like more information about reading data in Stata, see the
Stata
Learning Module on inputting raw data into Stata.
As an aside, you can actually read the raw data file comma.txt directly over the internet into Stata, using the following command:
insheet using http://www.ats.ucla.edu/stat/stata/faq/comma.txt
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services