Hi,
I get an error message when calculating binomial (95%CI) in the proc freq step because one of the 4 treatment groups have zero counts. How can I still proceed and output "(0.00, 0.00)" for 95% CI when there are zero counts?
proc sql;
create table ce1_1_3 as select distinct(usubjid), TRT01A, ceoccur/*, ceterm*/ from ce_1
where cetoxgrn>=3 order by usubjid;
quit;
data ce1_1_3;
merge adsl ce1_1_3;
by usubjid;
run;
proc sort data=ce1_1_3;
by trt01a;
run;
proc freq data=ce1_1_3 order=data;
by TRT01A;
table ceoccur/*ceterm*// missing exact binomial(level=2) cl;
ods output onewayfreqs=ae_freqs_soc_3 binomial=ae_ci_soc_3(where=(name1
in ('XL_BIN', 'XU_BIN')));
run;Thank you
Do you have only 1 level of CEOCCUR?
Yes only CEOCCUR='Y'
If there is only 1 level, you can't do this EXACT or Binomial analysis in PROC FREQ
Hi @HitmonTran,
You could (temporarily) introduce a weight variable and the second level of CEOCCUR with weight zero and then use the ZEROS option of the WEIGHT statement.
Simplified Example:
data have;
set sashelp.class;
if sex='F';
run;
data _tmp / view=_tmp;
set have end=last;
_w=1;
output;
if last then do;
sex='M';
_w=0;
output;
end;
run;
proc freq data=_tmp;
weight _w / zeros;
tables sex / exact binomial(level=2) cl;
run;
Result:
Cumulative Cumulative
Sex Frequency Percent Frequency Percent
--------------------------------------------------------
F 9 100.00 9 100.00
M 0 0.00 9 100.00
Binomial Proportion
Sex = M
Proportion 0.0000
ASE 0.0000
95% Lower Conf Limit 0.0000
95% Upper Conf Limit 0.0000
Exact Conf Limits
95% Lower Conf Limit 0.0000
95% Upper Conf Limit 0.3363
@Ksharp wrote:
Freelance,
How do you know which level is missing ? and which level is not missing ? write another data step ?
Thanks, @Ksharp, this is a good point when it comes to adapting my suggestion to @HitmonTran's actual data or to generalizing it. I just wanted to show that, in principle, the initial difficulty of calculating those confidence intervals for an empty category can be overcome. Indeed, more code would be needed to avoid hardcoding the missing level. Possibly all categories are contained in the input dataset ce1_1_3, but just not in every treatment BY-group.
Also, to make the PROC FREQ code more robust, I would probably specify the "level-value" rather than the level-number in the LEVEL= option, especially with regard to the MISSING option that is used in the OP's code (i.e., the number of a particular level depends on whether missing values of CEOCCUR exist).
PS: BTW, my name is Reinhard. And I'm a freelancer, hence my user name. :-)
@Ksharp wrote:
"PS: BTW, my name is Reinhard. And I'm a freelancer, hence my user name. :-)"
WOW, impressed ! Why not find a decent job since your SAS skill is so good !
Thanks. :-) I was offered the opportunity to start freelancing in 2010 because of my SAS skills and I'm still happy with my decision to take that chance.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.