11-22-2011 12:16 PM
I have this variable tobhrd3 (stands for: How many of you have heard of electronic cigarettes?). I want to find the % and 95% CI of each category (sex, age groups, race, income, education, region, etc) that has heard of electronic cigarettes. How do I do that? Not PROC FREQ or PROC UNIVARIATE. PROC TABULATE?
11-22-2011 01:04 PM
I might be confused, but can't you use PROC FREQ with a BY statement? Here's what I'm thinking (data for SEX):
input tobhrd3 sex;
value MF 1='Male' 0='Female';
proc freq data=a;
format sex MF.;
tables tobhrd3 / binomial(level=1);
The BINOMIAL option is described at http://support.sas.com/documentation/cdl/en/procstat/63963/HTML/default/viewer.htm#procstat_freq_a00...
It can be used only for one-way tables. Is that why you say "not PROC FREQ"?
11-22-2011 01:47 PM
I tried your way but I'm seeing output for just male and not female and 2 observations only. When I ran proc freq for tobhrd3 there are total of 2433 people that heard of electronic cigarettes. Something is not right..
11-22-2011 01:58 PM
It's not feasible to debug your code long distance, but
1) make sure your data are sorted by the BY group var
Do you correctly get the cross tab?
11-22-2011 02:53 PM
Calculate the % in a datastep if you're not using the default sas output from binomial as mentioned by Rick.
For results similar to Ricks that might be more useful you could consider doing the following:
ods table binomialprop=sample;
proc freq data=merged;
where name1 in ("_BIN_", "L_BIN", "U_BIN");
proc transpose data=sample2 out=answer;