Hi all,
I am trying to create a report that can be ran and exported to excel on a monthly basis but I'm stuck with creating loops every pair of columns.
All the variables in the report are going to be disaggregated by country (variable: centernum), using 2 columns by country "Column B: n/Mean" and "Column C: %/sd" as in the following example:
I wrote the following code:
However, I don't know how to specify that the %/sd should go in the following column so at the moment it overwrites what is already there and looks like this:
Any help on how to sort it would be of great help!
Thanks
I am trying to create a report that can be ran and exported to excel on a monthly basis but I'm stuck with creating loops every pair of columns.
All the variables in the report are going to be disaggregated by country (variable: centernum), using 2 columns by country "Column B: n/Mean" and "Column C: %/sd" as in the following example:
| Monthly data review TCU | ||||||||
| Total | Nigeria | Kenya | India-B | |||||
| n/Mean | %/sd | n/Mean | %/sd | n/Mean | %/sd | n/Mean | %/sd | |
| Enrolment flow | ||||||||
| Screened women | 71 | 100 | ||||||
| Eligible women | 50 | 70.42 | ||||||
| Randomized women | 49 | 69.01 | ||||||
| Women followed up at day 8 | 27 | 55.10 | ||||||
Code:
putexcel B2:C2=("Total") D2:E2=("Nigeria") F2:G2=("Kenya") H2:I2=("India-B") , merge bold hcenter border(all, thin, black)
local row = 3
local ncol = 2
levelsof centernum , local(centernum)
foreach y of local centernum {
local col : word `ncol' of `c(ALPHA)'
putexcel `col'3=("n/mean") `col'3=("%/sd"), bold hcenter border(all, thin, black)
local ++ncol
}
| Monthly data review TCU | ||||||||
| Total | Nigeria | Kenya | India-B | |||||
| %/sd | %/sd | %/sd | ||||||
| Enrolment flow | ||||||||
| Screened women | 71 | 100 | ||||||
| Eligible women | 50 | 70.42 | ||||||
| Randomized women | 49 | 69.01 | ||||||
Any help on how to sort it would be of great help!
Thanks

Comment