describe
Contains data from auto.dta obs: 74 vars: 12 17 Feb 1999 10:49 size: 3,108 (99.6% of memory free) ------------------------------------------------------------------------------- 1. make str17 %17s 2. price int %9.0g 3. mpg byte %9.0g 4. rep78 byte %9.0g 5. hdroom float %9.0g 6. trunk byte %9.0g 7. weight int %9.0g 8. length int %9.0g 9. turn byte %9.0g 10. displ int %9.0g 11. gratio float %9.0g 12. foreign byte %9.0g ------------------------------------------------------------------------------- Sorted by:
codebook make price
make -------------------------------------------------------------- (unlabeled)
type: string (str17)
unique values: 74 coded missing: 0 / 74
examples: "Cad. Deville"
"Dodge Magnum"
"Merc. XR-7"
"Pont. Catalina"
warning: variable has embedded blanks
price ------------------------------------------------------------- (unlabeled)
type: numeric (int)
range: [3291,15906] units: 1
unique values: 74 coded missing: 0 / 74
mean: 6165.26
std. dev: 2949.5
percentiles: 10% 25% 50% 75% 90%
3895 4195 5006.5 6342 11385
inspect mpg
mpg: Number of Observations
------ Non-
Total Integers Integers
| # Negative - - -
| # Zero - - -
| # Positive 74 74 -
| # # ----- ----- -----
| # # # Total 74 74 -
| # # # # . Missing -
+---------------------- -----
12 41 74
(21 unique values)
list make price mpg rep78 foreign in 1/10
make price mpg rep78 foreign 1. Dodge Magnum 5886 16 2 0 2. Datsun 510 5079 24 4 1 3. Ford Mustang 4187 21 3 0 4. Linc. Versailles 13466 14 3 0 5. Plym. Sapporo 6486 26 . 0 6. Plym. Arrow 4647 28 3 0 7. Cad. Eldorado 14500 14 2 0 8. AMC Spirit 3799 22 . 0 9. Pont. Catalina 5798 18 4 0 10. Chev. Nova 3955 19 3 0
tabulate rep74
tab rep74
rep78 | Freq. Percent Cum.
------------+-----------------------------------
1 | 2 2.90 2.90
2 | 8 11.59 14.49
3 | 30 43.48 57.97
4 | 18 26.09 84.06
5 | 11 15.94 100.00
------------+-----------------------------------
Total | 69 100.00
tabulate foreign or tab foreign
foreign | Freq. Percent Cum.
------------+-----------------------------------
0 | 52 70.27 70.27
1 | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00
tab1 rep74 foreign
-> tabulation of rep78
rep78 | Freq. Percent Cum.
------------+-----------------------------------
1 | 2 2.90 2.90
2 | 8 11.59 14.49
3 | 30 43.48 57.97
4 | 18 26.09 84.06
5 | 11 15.94 100.00
------------+-----------------------------------
Total | 69 100.00
-> tabulation of foreign
foreign | Freq. Percent Cum.
------------+-----------------------------------
0 | 52 70.27 70.27
1 | 22 29.73 100.00
------------+-----------------------------------
Total | 74 100.00
tabulate rep78, plot
rep78 | Freq.
------------+------------+-----------------------------------------------------
1 | 2 |**
2 | 8 |********
3 | 30 |******************************
4 | 18 |******************
5 | 11 |***********
------------+------------+-----------------------------------------------------
Total | 69
tabulate rep78 foreign
| foreign
rep78 | 0 1 | Total
-----------+----------------------+----------
1 | 2 0 | 2
2 | 8 0 | 8
3 | 27 3 | 30
4 | 9 9 | 18
5 | 2 9 | 11
-----------+----------------------+----------
Total | 48 21 | 69
summarize mpg
Variable | Obs Mean Std. Dev. Min Max
---------+-----------------------------------------------------
mpg | 74 21.2973 5.785503 12 41
summarize mpg, detail
mpg
-------------------------------------------------------------
Percentiles Smallest
1% 12 12
5% 14 12
10% 14 14 Obs 74
25% 18 14 Sum of Wgt. 74
50% 20 Mean 21.2973
Largest Std. Dev. 5.785503
75% 25 34
90% 29 35 Variance 33.47205
95% 34 35 Skewness .9487176
99% 41 41 Kurtosis 3.975005
mean price mpg
Mean estimation Number of obs = 74
--------------------------------------------------------------
| Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
price | 6165.257 342.8719 5481.914 6848.6
mpg | 21.2973 .6725511 19.9569 22.63769
--------------------------------------------------------------
sort price
+-------+ +-------+
| price | | price |
|-------| |-------|
1. | 4,099 | 1. | 3,291 |
2. | 4,749 | 2. | 3,299 |
3. | 3,799 | --> 3. | 3,667 |
4. | 4,816 | 4. | 3,748 |
5. | 7,827 | 5. | 3,798 |
+-------+ +-------+
Shown top 5 observations
gsort -price
+-------+ +--------+
| price | | price |
|-------| |--------|
1. | 4,099 | 1. | 15,906 |
2. | 4,749 | 2. | 14,500 |
3. | 3,799 | --> 3. | 13,594 |
4. | 4,816 | 4. | 13,466 |
5. | 7,827 | 5. | 12,990 |
+-------+ +--------+
Shown top 5 observations
order foreign
+---------------------------------+ +---------------------------------------+
| make price mpg | | foreign make price |
|---------------------------------| |---------------------------------------|
1. | Cad. Seville 15,906 21 | 1. | Domestic Cad. Seville 15,906 |
2. | Cad. Eldorado 14,500 14 | 2. | Domestic Cad. Eldorado 14,500 |
3. | Linc. Mark V 13,594 12 | --> 3. | Domestic Linc. Mark V 13,594 |
4. | Linc. Versailles 13,466 14 | 4. | Domestic Linc. Versailles 13,466 |
5. | Peugeot 604 12,990 14 | 5. | Foreign Peugeot 604 12,990 |
+---------------------------------+ +---------------------------------------+
Operator & and; | or; != not equal to // use "~=" == equal when using 'if' > more than // >= more than or equal to < less than // <= less than or equal to _n row number _N total observations
E.g. gen new_var1 = 1 if foreign == 1
gen new_var2 = 1 if foreign == 1 & rep78 == 3
gen new_var3 = 1 if foreign == 1 & rep78 != 3
egen new_mean_var = mean(price)
(1) UCLA: https://stats.idre.ucla.edu/stata/ (2) IPA: https://www.poverty-action.org/researchers/research-resources/stata-programs