Hi there. This is a (seemingly) simple task but is giving me some grief! Hoping someone can help.
I have a number of categorical variables I want to simply summarize into frequencies(proportions) in a table. Ideally I could get this all within the same output/results so that they are easy to copy/align to excel in one go (and then subsequently link to a clean table). I need to extract the proportions AND frequencies from the output - but seem to be able only do one OR the other using separate commands (i.e. via using either proportion or tab - see below). Problem with doing both separately is it means different formats of result to copy/extract (so they don't align well when pasting into excel).
proportion familyhistory_3cat educ_cat3 ethn3 occup_3 marital_cat2 alcohol_cat smokstatus_2 bmigrp_12 ///
if subpopulation==1
foreach var of varlist familyhistory_3cat educ_cat3 ethn3 occup_3 marital_cat2 alcohol_cat smokstatus_2 bmigrp_12 {
tab `var' if subpopulation==1
}
I would like to look at these in a subpopulation (as above), but then break down further by gender (male/female), if possible.
The easiest solution would be if I could somehow run the first proportion command above (which allows me to add multiple variables at once and they come out in a cleanly aligned table), but then append another column to this output that includes frequencies as well - is this possible? Of course put excel is another option - but surely this can be done more simply?
Hope that was clear. Many thanks!
Patrick.
I have a number of categorical variables I want to simply summarize into frequencies(proportions) in a table. Ideally I could get this all within the same output/results so that they are easy to copy/align to excel in one go (and then subsequently link to a clean table). I need to extract the proportions AND frequencies from the output - but seem to be able only do one OR the other using separate commands (i.e. via using either proportion or tab - see below). Problem with doing both separately is it means different formats of result to copy/extract (so they don't align well when pasting into excel).
proportion familyhistory_3cat educ_cat3 ethn3 occup_3 marital_cat2 alcohol_cat smokstatus_2 bmigrp_12 ///
if subpopulation==1
foreach var of varlist familyhistory_3cat educ_cat3 ethn3 occup_3 marital_cat2 alcohol_cat smokstatus_2 bmigrp_12 {
tab `var' if subpopulation==1
}
I would like to look at these in a subpopulation (as above), but then break down further by gender (male/female), if possible.
The easiest solution would be if I could somehow run the first proportion command above (which allows me to add multiple variables at once and they come out in a cleanly aligned table), but then append another column to this output that includes frequencies as well - is this possible? Of course put excel is another option - but surely this can be done more simply?
Hope that was clear. Many thanks!
Patrick.
Comment