Hi all. I created the following table using putexcel below. The standard deviations are in the row below the mean estimate which is presented on the same row as the variable name. I am trying to place the standard deviation in parentheses. My approach has *unsuccesfully* been to write the standard deviation as a string and then add parentheses around them; however, instead it just writes the text r(sd) where the standard deviations are currently written in. Any help will be very much appreciated. I have the code and data extract below.
```
clear
input long efteug byte(control actcm75 acten75 actmt75) float admissions_r
4902 1 19 20 18 89.86304
5163 1 19 20 18 91.75279
5447 1 20 20 18 89.64993
4632 1 20 20 18 71.60061
4315 1 19 20 18 68.395645
11804 1 29 31 26 92.10963
12185 1 29 32 27 73.6563
12367 1 30 33 27 80.59859
12316 1 30 33 28 88.53519
12105 1 30 33 28 86.6794
```
```
*Create title, column and row labels
putexcel A1 = "Mean and Standard Deviation Estimates by School Type"
putexcel (A1:E1), bold border(bottom) merge hcenter
putexcel B2 = "Public"
putexcel C2 = "Private, not-for-profit"
putexcel D2 = "Private, for-profit"
*Create local to loop over so that each variable is outputted onto a separate row
local ivar = 3
local varlist "admissions_r actmt75 acten75 actcm75"
putexcel A3 = "Admissions Rate"
putexcel A5 = "ACT Total Score"
putexcel A7 = "ACT English Score"
putexcel A9 = "ACT Math Score"
*Loop over the variables and output to the excel sheet
foreach varnm in admissions_r actmt75 acten75 actcm75 {
qui sum `varnm' [w=efteug] if control==1
putexcel B`ivar' = (r(mean))
putexcel B`=`ivar' + 1' = "(r(sd))"
qui sum `varnm' [w=efteug] if control==2
putexcel C`ivar' = (r(mean))
putexcel C`=`ivar' + 1' = "(r(sd))"
qui sum `varnm' [w=efteug] if control==3
putexcel D`ivar' = (r(mean))
putexcel D`=`ivar' + 1' = "(r(sd))"
local ivar = `ivar' +2
}
```
Mean and Standard Deviation Estimates by School Type | ||||
Public | Private, not-for-profit | Private, for-profit | ||
Admissions Rate | 70.7788 | 62.58593 | 74.48127 | |
19.78113 | 26.32171 | 19.36803 | ||
ACT Total Score | 26.84303 | 28.08913 | 23.3492 | |
3.406976 | 4.011796 | 3.499239 | ||
ACT English Score | 28.07645 | 29.82348 | 23.83472 | |
4.302951 | 4.751662 | 3.98307 | ||
ACT Math Score | 27.55648 | 29.10187 | 27.05202 | |
3.582493 | 4.069271 | 3.918478 |
```
clear
input long efteug byte(control actcm75 acten75 actmt75) float admissions_r
4902 1 19 20 18 89.86304
5163 1 19 20 18 91.75279
5447 1 20 20 18 89.64993
4632 1 20 20 18 71.60061
4315 1 19 20 18 68.395645
11804 1 29 31 26 92.10963
12185 1 29 32 27 73.6563
12367 1 30 33 27 80.59859
12316 1 30 33 28 88.53519
12105 1 30 33 28 86.6794
```
```
*Create title, column and row labels
putexcel A1 = "Mean and Standard Deviation Estimates by School Type"
putexcel (A1:E1), bold border(bottom) merge hcenter
putexcel B2 = "Public"
putexcel C2 = "Private, not-for-profit"
putexcel D2 = "Private, for-profit"
*Create local to loop over so that each variable is outputted onto a separate row
local ivar = 3
local varlist "admissions_r actmt75 acten75 actcm75"
putexcel A3 = "Admissions Rate"
putexcel A5 = "ACT Total Score"
putexcel A7 = "ACT English Score"
putexcel A9 = "ACT Math Score"
*Loop over the variables and output to the excel sheet
foreach varnm in admissions_r actmt75 acten75 actcm75 {
qui sum `varnm' [w=efteug] if control==1
putexcel B`ivar' = (r(mean))
putexcel B`=`ivar' + 1' = "(r(sd))"
qui sum `varnm' [w=efteug] if control==2
putexcel C`ivar' = (r(mean))
putexcel C`=`ivar' + 1' = "(r(sd))"
qui sum `varnm' [w=efteug] if control==3
putexcel D`ivar' = (r(mean))
putexcel D`=`ivar' + 1' = "(r(sd))"
local ivar = `ivar' +2
}
```
Comment