This module will show how to read a small raw data file within a Stata program. Consider the sample program below.
. clear
. input str3 make mpg rep78 weight foreign
make mpg rep78 weight foreign 1. AMC 22 3 2930 0 2. AMC 17 3 3350 0 3. AMC 22 . 2640 0 4. end
We can use the list command to see that the data was read properly.
. list
make mpg rep78 weight foreign 1. AMC 22 3 2930 0 2. AMC 17 3 3350 0 3. AMC 22 . 2640 0
Now that we have read the data, let's do some summary statistics.
. summarize
Variable | Obs Mean Std. Dev. Min Max
---------+-----------------------------------------------------
make | 0
mpg | 3 20.33333 2.886751 17 22
rep78 | 2 3 0 3 3
weight | 3 2973.333 356.9781 2640 3350
foreign | 3 0 0 0 0
and lets tabulate mpg
. tab mpg
mpg | Freq. Percent Cum.
------------+-----------------------------------
17 | 1 33.33 33.33
22 | 2 66.67 100.00
------------+-----------------------------------
Total | 3 100.00