BookmarkSubscribeRSS Feed
HitmonTran
Pyrite | Level 9

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?

HitmonTran_0-1623672779615.png

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

8 REPLIES 8
PaigeMiller
Diamond | Level 26

Do you have only 1 level of CEOCCUR?

--
Paige Miller
PaigeMiller
Diamond | Level 26

If there is only 1 level, you can't do this EXACT or Binomial analysis in PROC FREQ

--
Paige Miller
FreelanceReinh
Jade | Level 19

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
Super User
Freelance,
How do you know which level is missing ? and which level is not missing ? write another data step ?
FreelanceReinh
Jade | Level 19

@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
Super User
"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 !
FreelanceReinh
Jade | Level 19

@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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2445 views
  • 6 likes
  • 4 in conversation