Hi, I am trying to calculate the relative risk of SMM per province and obtain different RR estimates for each province with ON as the reference.
My data looks something like this:
I have tried different methods but none is working. Please help.
Method 1 using binomial does not give me separate RRs. I also saw somewhere about removing the "param" and estimate line but this did not work either, neither does using NLMeans macro.
proc genmod data= smm.uvu descending;
class province1(ref='ON')/ param=ref;
model SMM = province1/d=bin link=log;
estimate 'SMM RR by province' province1 1/exp;
lsmeans province1 / diff exp cl;
title "RR SMM type by province";
run;
Method 2. The proc freq method below is only giving me 2*2 freq without any RR:
proc freq data=uvu2 order=data;
tables province1*SMM/relrisk;
run;
It looks like proc freq only does relative risk for 2x2 tables. So you could create a dataset with a sequence of province pairs, i.e. all the 'AB' and 'ON' observations (pair_num=1), then all the 'BC' and 'ON' observations (pair_num=2). Then you could do a sequence of 2x2 tables using PROC FREQ -- BY PAIR_NUM, as here:
data ON;
set have (where=(province='ON'));
run;
data test ;
set have (where=(province^='ON'));
by province ;
retain pairnum 0 pairing 'XX vs YY';
if first.province then do;
pairnum+1;
pairing=catx(' ',province,'vs','ON');
end;
output;
if last.province then do ptr=1 to n_on;
set ON nobs=n_on point=ptr;
output;
end;
run;
proc freq data=test;
by pairnum pairing;
tables province*smm / nopercent nocol ;
exact relrisk (column=2 method=noscore);
run;
I used the "method=noscore" option because it is much faster than the default (method=score). Take a look at the RELRISK <(options)> section of the EXACT statement documentation. If you have a lot of pairings to examine, you might want to test this on just a couple to get an idea of how long it will take to run.
And on another note, I don't know how much "confidence" one can have in a set of relrisk confidence limits when each set re-use the same province=ON data. That's an estimation problem that I never had to face.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.