Hi all, it may be a stupid question but I am having trouble generating frequency table directly from stata and hopefully stata can help me export to excel. The final product I was expecting is something like the following:
and I have six more categories just like the Gender shown above. All I need is the frequency and percent for inactive, and active and a total frequency (adding inactive and active) and percent.
For now I can generate frequency table using the following syntax but this only covers one category (such as gender) and also it cannot give me the total part
Any clues please? Thanks!
| Inactive (n=9,728) |
Active (n=2,633) |
Total (n=12,361) |
||||
| Gender | ||||||
| Female | 3,325 | 0.436 | 1,221 | 0.569 | 4,546 | 0.465 |
| Male | 4,304 | 0.564 | 923 | 0.431 | 5,227 | 0.535 |
For now I can generate frequency table using the following syntax but this only covers one category (such as gender) and also it cannot give me the total part
Code:
tab Gender Status, matcell(freq) matrow(names)
matrix list freq
matrix list names
putexcel A1=("Gender") B1=("Inactive") C1=("Active") using results1, replace
putexcel A2=matrix(names) B2=matrix(freq) using results1, modify

Comment