Using table and collect not very often I am struggling with the collect commands.
I am using
amd get
How to get a horizontal line above the Total?
I am using
Code:
clear
* Example generated by -dataex-. For more info, type help dataex
clear
input float grade_st byte age
14 13
14 14
14 15
14 14
16 16
14 14
15 16
15 15
14 14
14 14
14 14
15 15
15 15
16 16
14 13
15 15
14 14
15 15
14 14
16 16
14 14
13 13
16 16
13 13
14 15
13 14
15 15
16 16
15 15
13 14
16 16
16 17
17 19
15 15
13 13
16 18
14 .a
14 14
14 15
16 16
15 16
16 17
15 15
15 .a
18 16
18 18
16 16
15 15
17 17
14 14
14 13
16 16
13 13
15 14
15 14
17 18
14 14
13 13
17 17
16 16
13 13
15 14
13 13
end
label values age age
label def age .a "no answer", modify
qui table grade_st, statistic(n age) statistic(mean age) statistic(sd age) ///
statistic(min age) statistic(max age)
collect label levels result count "Obs" mean "Mean" sd "Std. dev." ///
min "Min" max "Max", modify
collect style cell result[mean sd], nformat(%4.1f)
collect style cell result[count min max], nformat(%6.0fc)
collect preview
Code:
. collect preview
----------------------------------------------
| Obs Mean Std. dev. Min Max
---------+------------------------------------
grade_st |
13 | 9 13.2 0.4 13 14
14 | 18 14.0 0.6 13 15
15 | 15 14.9 0.6 14 16
16 | 13 16.3 0.6 16 18
17 | 4 17.8 1.0 17 19
18 | 2 17.0 1.4 16 18
Total | 61 15.0 1.5 13 19
----------------------------------------------

Comment