According to the "putdocx table" documentation, it should be possible to format cells in the table, as in line 10 in the script below.. E.g for means I get 7.861702 which I want to reduce to two decimal points. The loop works well, but when I try to format cells by inserting a nformat command (line 10) I get the error message "option not allowed".
Anybody know how to reduce number of decimals in this example?
I am using Stata SE 15.0
.
. forvalues i = 3/150{
2. putdocx paragraph, halign(left)
3. putdocx text ("Kommune `: label (K) `i''"), bold
4. foreach var in Fornøydhet Meningsfylt Ensom{
5.
. putdocx paragraph, halign(center)
6. putdocx text ("`var'")
7. preserve
8. statsby n=r(N) mean=r(mean) se=r(se) lb=r(lb) ub=r(ub), by(aldergr3) clear: ci mean `var' if K==`i'
9. putdocx table `var' = data("n mean se lb ub aldergr3"), varnames border(start, nil) border(insideV, nil) border(end, nil)
10. putdocx table `var'(2,3), nformat(%5.2f)
11.
.
. restore
12. }
13. }
(running ci on estimation sample)
command: ci mean Fornøydhet if K==3
n: r(N)
mean: r(mean)
se: r(se)
lb: r(lb)
ub: r(ub)
by: aldergr3
Statsby groups
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
...
option nformat(%5.2f) not allowed
Related Posts with Formatting cells putdocx table
Meta Command for prevalencesI'm trying to run a meta-analysis using the metan command for a rate of the progression outcome vari…
Tabout and Fre suddenly not working?For some reason when I export frequency tables to excel and/or word (as .csv or .rtf files), they ar…
Keep a group of observations if one record meets a certain conditionHi All, Here's an example of the sort of dataset that I'm working with: clear input studyid edvisi…
Multilevel regresion code doubtHi all, I have date of 100 employees per company, for several companies. I would like to perform a …
Break in consecutive values to identify groupsSuppose I have a dataset like this: clear set obs 20 gen x = 1 gen id = 1 in 1/10 replace id = …
Subscribe to:
Post Comments (Atom)
0 Response to Formatting cells putdocx table
Post a Comment