BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cmendoza87
Obsidian | Level 7

Hello,

I am trying to measure relative risk and risk difference on a 3-categorical variable. I was easily able to calculate risk difference using a binary variable and proc surveyfreq:

PROC SURVEYFREQ DATA=full ORDER=DATA;
STRATA strat;
CLUSTER PSU_ID;
WEIGHT weight_final_norm_overall;
TABLE KEEP_dssamp1*eids_user*PreCKD /row CL RISK OR;
RUN;

eids_user is a binary variable (0=non-user, 1=user). I was also able to calculate risk difference easily using proc surveyreg:

PROC SURVEYREG DATA=full; 
STRATA strat;
CLUSTER PSU_ID;
WEIGHT weight_final_norm_overall;
DOMAIN KEEP_dssamp1;
MODEL PreCKD = eids_user /SOLUTION;
ESTIMATE 'DS user' int 1 eids_user 1 /E CL;
ESTIMATE 'non-user' int 1 eids_user 0 /E CL;
ESTIMATE 'PD USER vs non-user' int 0 eids_user 1 /E CL;
RUN;

 

Thank you!

 

I would like to do the above with a 3-category variable (eids_user_freq2) that takes into account frequency of use (0=non-user, 1=infrequent user, 2=frequent user) but when I do the above statements using this variable, I get percentage estimates and risk difference but not relative risk. I could manually calculate the relative risk but I wanted to see if one of the proc survey commands can calculate it. I used the code below:

PROC SURVEYFREQ DATA=full ORDER=DATA;
STRATA strat;
CLUSTER PSU_ID;
WEIGHT weight_final_norm_overall;
TABLE KEEP_dssamp1*eids_user_freq2*PreCKD /row CL RISK OR;
RUN;

 

PROC SURVEYREG DATA=full ORDER=DATA;
STRATA strat;
CLUSTER PSU_ID;
WEIGHT weight_final_norm_overall;
DOMAIN KEEP_dssamp1;
CLASS eids_user_freq2;
MODEL PreCKD = eids_user_freq2 /SOLUTION;
ESTIMATE 'non user' intercept 1 eids_user_freq2 1 0 0 /E CL;
ESTIMATE 'infrequent user' int 1 eids_user_freq2 0 1 0 /E CL;
ESTIMATE 'frequent user' int 1 eids_user_freq2 0 0 1 /E CL;
ESTIMATE 'frequent vs non-user' int 0 eids_user_freq2 -1 0 1 /E CL EXP;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

You can use the NLMeans macro as shown in this note. The note illustrates its use with PROC LOGISTIC, but the same can be done by fitting the model in PROC SURVEYLOGISTIC. You'll specify your response variable and both predictors in the MODEL statement and your 3-level variable in the LSMEANS statement: 

model PreCKD = KEEP_dssamp1 eids_user_freq2;
lsmeans eids_user_freq2 / e ilink;

and then use the NLMeans macro as shown in the note. It will provide all pairwise relative risk estimates among your three levels. Note that these estimates are adjusted for the other predictor in the model.

View solution in original post

4 REPLIES 4
StatDave
SAS Super FREQ

You can use the NLMeans macro as shown in this note. The note illustrates its use with PROC LOGISTIC, but the same can be done by fitting the model in PROC SURVEYLOGISTIC. You'll specify your response variable and both predictors in the MODEL statement and your 3-level variable in the LSMEANS statement: 

model PreCKD = KEEP_dssamp1 eids_user_freq2;
lsmeans eids_user_freq2 / e ilink;

and then use the NLMeans macro as shown in the note. It will provide all pairwise relative risk estimates among your three levels. Note that these estimates are adjusted for the other predictor in the model.

cmendoza87
Obsidian | Level 7

Thank you for your response and apologies for the delay in responding!

 

This worked! I also used it to check that the risk ratio estimates from the macro were the same as the PROC FREQ estimates when using a binary variable. Do you happen to know the estimation method used to calculate the confidence interval in the NLMEANS macro? It is different from the PROC FREQ estimation of confidence interval because the interval estimates are slightly different from each other. 

 

Thank you!!!!!

StatDave
SAS Super FREQ
This is stated in the Details section of the macro documentation. As stated there, the standard error (which is used to compute the confidence limits) is computed using the statistical delta method.
cmendoza87
Obsidian | Level 7
ahh I see that now, thank you!

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!

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
  • 4 replies
  • 1178 views
  • 2 likes
  • 2 in conversation