*-
https://bbs.pinggu.org/thread-1070298-1-1.html
*-在你的数据中, 你可以把 age 替换成 year
sysuse nlsw88, clear
keep if age<40
tab age race, row // case I
tab age race, row nofreq // case II
*-结果
. tab age race, row // case I
+----------------+
| Key |
|----------------|
| frequency |
| row percentage |
+----------------+
age in |
current | race
year | white black other | Total
-----------+---------------------------------+----------
34 | 37 15 1 | 53
| 69.81 28.30 1.89 | 100.00
-----------+---------------------------------+----------
35 | 183 74 3 | 260
| 70.38 28.46 1.15 | 100.00
-----------+---------------------------------+----------
36 | 184 71 2 | 257
| 71.60 27.63 0.78 | 100.00
-----------+---------------------------------+----------
37 | 146 75 4 | 225
| 64.89 33.33 1.78 | 100.00
-----------+---------------------------------+----------
38 | 158 59 2 | 219
| 72.15 26.94 0.91 | 100.00
-----------+---------------------------------+----------
39 | 165 67 2 | 234
| 70.51 28.63 0.85 | 100.00
-----------+---------------------------------+----------
Total | 873 361 14 | 1,248
| 69.95 28.93 1.12 | 100.00
. tab age race, row nofreq // case II
age in |
current | race
year | white black other | Total
-----------+---------------------------------+----------
34 | 69.81 28.30 1.89 | 100.00
35 | 70.38 28.46 1.15 | 100.00
36 | 71.60 27.63 0.78 | 100.00
37 | 64.89 33.33 1.78 | 100.00
38 | 72.15 26.94 0.91 | 100.00
39 | 70.51 28.63 0.85 | 100.00
-----------+---------------------------------+----------
Total | 69.95 28.93 1.12 | 100.00