BookmarkSubscribeRSS Feed
SteffenF
Fluorite | Level 6

I want to calculate the confidence interval for a relative risk in a 2x2 table (X * Y).

 

For a reason - not relevant for this topic - I would like to use PROC PHREG to accomplish this.

 

Strangely, with PROC PHREG I only get the same confidence interval as with procedure PROC FREQ or PROC GENMOD,
when I use the EVENTCODE=1 option in PHREG. Since there are only two possible levels for Y (0/1), I do not understand
how this option can have an impact on the result.

 

When I do not use  the EVENTCODE=1 option, the confidence interval for the relative risk is much wider and seems inappropriate given the discrepancy with the results from PROC FREQ and PROC GENMOD

 

Any suggestions are more than welcome!

/*simulate data such the the relative risk equals 1.5 (60% if x=1 versus 40% if x=0)*/
data test;
do x=0 to 1;
 do id=1 to 100;
  if x=0 then  y=(id>40);
  if x=1 then  y=(id>60);
  output;
 end;
end;
run;

title 'Using PROC FREQ';
ods select none;
proc freq data=test;
 tables x*y/nocol  nocum nopercent relrisk  ;
 ods output relativerisks=relrisk_FREQ;
run;
ods select all;
proc print data=relrisk_FREQ noobs label; var value LowerCL UpperCL;where statistic="Relative Risk (Column 2)";format _numeric_ 8.5;run;

title 'Using PROC GENMOD';
ods select none;
proc genmod data=test ;
 model y=x/dist=bin link=log;
 estimate 'RR' x 1/exp;
 ods output estimates=relrisk_GENMOD;
run;
ods select all;
proc print data=relrisk_GENMOD noobs label; where label="Exp(RR)";var LBetaEstimate LBetaLowerCL LBetaUpperCL;format _numeric_ 8.5;run;

title 'Using PROC PHREG - with eventcode specification';
ods select none;
data test;set test;FUtime=1;run;
proc phreg data=test;
class x;
model FUtime*y(0)=x/eventcode=1 rl;
ods output parameterestimates=RR_phreg;
run;
ods select all;
proc print data=RR_phreg noobs;var hazardratio HRLowerCL HRUpperCL;format _numeric_ 8.5;run;

title 'Using PROC PHREG - without eventcode specification';
ods select none;
data test;set test;FUtime=1;run;
proc phreg data=test;
class x;
model FUtime*y(0)=x/ rl;
ods output parameterestimates=RR_phreg;
run;
ods select all;
proc print data=RR_phreg noobs;var hazardratio HRLowerCL HRUpperCL;format _numeric_ 8.5;run;
2 REPLIES 2
Norman21
Lapis Lazuli | Level 10

I get errors in the log when I run your code, but output in results viewer.

 

Have you checked your log to make sure the program is running as it should?

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

SteffenF
Fluorite | Level 6

Dear Norman,

 

Thanks for your response!

 

I do not get any error in the log.

 

The version I'm working with is SAS 9.4 (TS1M3) X64_8PRO WIN 6.2.9200 (hence, slightly different)

 

Kind regards,

Steffen

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1576 views
  • 0 likes
  • 2 in conversation