Hi everyone,
If you combine graphs by using addplot, and you want to see the combination graphs from two subgroups, how should you/can you use the by(subgroup) -option? Example:
I have tried to add it to the twoway -command, and that gives me two scatterplots but w/o the collapse-products, and if I stuff by(sex) to other script lines, it won't be accepted.
Anyone?
Thanks in advance!
Mikko
If you combine graphs by using addplot, and you want to see the combination graphs from two subgroups, how should you/can you use the by(subgroup) -option? Example:
twoway scatter TMGLUC min,sortI would like to have both the scatter and the collapse -yieldings for both groups; let's say subgroups is sex (male=1, female=2). So, where should I add the by(sex)?
preserve
collapse (mean) mean_T= TMGLUC (semean) se_T= TMGLUC (sd) sd_T= TMGLUC (count) n_T= TMGLUC (p95) p95_T= TMGLUC,by(min)
gen lo= mean_T-1.96* se_T
gen hi= mean_T+1.96* se_T
graph addplot line mean_T lo hi min,sort legend(off)
restore
I have tried to add it to the twoway -command, and that gives me two scatterplots but w/o the collapse-products, and if I stuff by(sex) to other script lines, it won't be accepted.
Anyone?
Thanks in advance!
Mikko
Comment