Hi,
I want to calculate Confidence interval for attributable risk percent and population attributable risk percent ,in multivariable model.
I have used the following formulas to calculate the risks. I derived adjusted OR using proc logistic.
I was wondering how should i calculate CI for them ?
Adjusted Odds Ratio and CI from SAS
neverexposed 0 vs 1
1.271  1.178  1.371 
5.014  4.259  5.903 
4.430  3.636  5.396 
4.094  3.601  4.655 
1.190  0.973  1.454 
4.813  3.339  6.937 
4.333  3.754  5.002 
6.263  4.704  8.340 
0.722  0.602  0.867 
4.814  4.154  5.578 
1.896  1.526  2.355 
1.972  1.593  2.440 
0.942  0.750  1.181 
1.291  1.048  1.589 
1.492  1.221  1.824 
1.299  1.065  1.584 
1.222  1.000  1.493 
1.127  0.919  1.382 
1.084  0.880  1.337 
1.404  1.112  1.773 
0.705  0.641  0.776 
0.240  0.182  0.317 
0.558  0.434  0.718 
0.405  0.310  0.529 
>999.999  <0.001  >999.999 
0.419  0.323  0.545 
0.315  0.239  0.416 
1.324  0.311  5.636 
1.037  0.728  1.477 
2.079  1.181  3.659 
1.820  0.461  7.194 
1.871  0.560  6.246 
3.779  3.326  4.295 
1.053  0.933  1.188 
1.606  1.416  1.820 
2.422  2.098  2.795 
3.027  2.505  3.658 
1.653  1.429  1.913 
2.990  2.609  3.427 
5.580  4.885  6.374 
8.163  7.139  9.334 
9.616  8.320  11.114 
11.041  9.733  12.524 
7.674  6.494  9.068 
1.271  1.178  1.371 
As shown in this note, the attributable risk is defined as (R_e  R_u)/R_e, where R_e is the risk in the exposed group and R_u is the risk in the unexposed group. In a logistic model, these risks would be predicted event probabilities for your two groups and can be estimated (averaged over the other predictors) using the LSMEANS/ILINK statement. Since each risk is just a nonlinear function of the model parameters, the attributable risk is also a nonlinear function of the parameters. Such functions can be estimated using the NLEST macro. In the current release, SAS 9.4 TS1M6, the NLEST macro is available for immediate calling. In earlier releases, where it is known as the NLEstimate macro, it is available for download in this SAS Sample program.
The following statements fit a logistic model to the seed germination data in the Example titled "Overdispersion" in the LOGISTIC documentation. For this example, we will use the SOIL variable as the exposure indicator variable, where SOIL =1 represents the exposed group. The LSMEANS statement provides estimates of the risk of response (germination) in each group averaged over the levels of the other predictor, CULT. The E option shows the coefficients of the linear combination of model parameters used for each estimate. In the DATA FD step below, the risk for each group is recomputed using those coefficients and the nonlinear inverse of the logit. The third row of that data set defines the attributable risk as shown above. The NLEST macro is then called to reestimate the two risks (note the agree with the Mean column in the LSMEANS table) and estimate the attributable risk, along with tests and confidence intervals.
For the population attributable risk, the overall risk, R, is estimated by applying the inverse logit function to the average of the log odds for the two SOIL levels. The average log odds is the average of the two linear combinations shown in the LSMEANS coefficients table. For this model, that average is the intercept plus onehalf of each of the CULT and SOIL parameter estimates.
proc logistic data=seeds;
class cult soil / param=glm;
model r/n=cult soil;
lsmeans soil / e ilink;
store out=log;
run;
data fd;
length label f $32767;
infile datalines delimiter=',';
input label f;
datalines;
Risk soil=1,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk soil=0,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
Pop. Attr. Risk, ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+0.5*B_p4+0.5*B_p5)))1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+0.5*B_p4+0.5*B_p5))) )
;
%NLEst( instore=log, fdata=fd )
Hi,
I tried running the SAS with your help. still have few questions. Please help!
I have SAS (r) Proprietary Software 9.4 (TS1M4). Outcome is case. exposure variable is neverexposed.
other variables are studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq
i tried running the following SAS codes 
proc logistic data=red.merged3;
class studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed/ param=glm;
model case=studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed;
lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq / e ilink diff exp;
store out=log;
run;
data fd;
length label f $32767;
infile datalines delimiter=',';
input label f;
datalines;
Risk neverexposed=1,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
;
%NLEst( instore=log, fdata=fd )
Log i got is below;
proc logistic data=red.merged3;
523 class studyname ageq sex Education_levelmi1 race region drink_dayq
523! tobaccoyearq neverexposed/ param=glm;
524 model case=studyname ageq sex Education_levelmi1 race region
524! drink_dayq tobaccoyearq neverexposed;
525 lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq
525! tobaccoyearq / e ilink diff exp;
526 store out=log;
527 run;
NOTE: PROC LOGISTIC is modeling the probability that case='1'. One way
to change this to model the probability that case='2' is to
specify the response variable option EVENT='2'.
NOTE: Convergence criterion (GCONV=1E8) satisfied.
NOTE: The LOGISTIC procedure generated the model item store WORK.LOG.
NOTE: There were 22569 observations read from the data set RED.MERGED3.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 7.19 seconds
cpu time 1.40 seconds
528 data fd;
529 length label f $32767;
530 infile datalines delimiter=',';
531 input label f;
532 datalines;
NOTE: The data set WORK.FD has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
WARNING: Apparent invocation of macro NLEST not resolved.
536 ;
537
538
539 %NLEst( instore=log, fdata=fd )

180
ERROR 180322: Statement is not valid or it is used out of proper order.
Plese let me know what should i do.
Thanks
As I said, the NLEst (or equivalent NLEstimate) macro is only immediately available for use in the current release, SAS 9.4 TS1M6. For your earlier release, you will need to download the macro from the link I provided. Follow the instructions in the Usage section to make it available during your SAS session.
You will not be able to simply copy and paste the code I used for the example I gave. What you specify in the f variable in the fdata= data set (or in the f= option) of the macro depends on the model that you are working with. This is all described and illustrated in the macro documentation and the many notes that show examples of using the macro.
Note that your formula based on the odds ratio is only an approximation of the attributable risk when the event probability is small so that the odds ratio approximates the relative risk. In that case, your formula is approximately the same as an alternative formula for the attributable risk, (RR1)/RR, where RR is the relative risk.
Thank you very much for your patience and quick response.
I was able to download the macro and make it available to use as you said. However , i still need to figure out what to put in below part as my model has multiple variables. If you have any resources for that, that will be great help. Thanks in advance.
Risk neverexposed=1,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
%inc "C:\Users\khetap03\Desktop\three\nlestimate.sas";
proc logistic data=red.merged3;
class studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed/ param=glm;
model case= studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed;
lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq / e ilink diff exp;
store out=log;
run;
data fd;
length label f $32767;
infile datalines delimiter=',';
input label f;
datalines;
Risk neverexposed=1,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5)))1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp((B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
;
%NLEstimate( instore=log, fdata=fd )
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.