## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# SAS MACRO FOR CONFIDENCE INTERVALS

``` /*
Note: If variables are formatted then the formats will
need to be placed before the macro.
*/
options nocenter linesize=80 nonotes ;
%macro adaptci(dataset=, y=, xr=, xa=, seedl=, seed2=,seed3=,
maxsteps=8000);
data dseed;
nextl=&seedl;
next2=&seed2;
next3=&seed3;
data dupdate;
c=0;
data dgarth(keep=&y &xr &xa);
retain n 0;
set &dataset;```
`n = n + 1 ; call symput(‘nobs’,trim(left(put(n,8.) ) ) ); output; proc reg data=dgarth; model &y=&xr &xa/clb; titlel ‘ Regression Analysis with 95% Confidence Intervals ’; /* Now begin finding the adaptive estimate for parameter */ proc glm data=dgarth noprint; model &y=&xr; output out=dresid predicted=yhat1 residual=res; title2 ‘Adaptive weighted least squares analysis’; %adaptwtsl(datares=dresid, resvars=res, nobs=&nobs, nvars=l); data dall; merge dgarth dresid dweights; proc print data=dall ; var &y &xr &xa res weight saswt; title2‘ Data, after adjustment SASWT=weights used by SAS’; proc reg data=dall outest=dunperm outseb noprint; model &y = &xr &xa; weight saswt; data dtunperm(keep=tunperm beta); set dunperm; retain beta; if _type_ eq ‘PARMS’ then beta=&xa; if _type_ eq ‘SEB’ then do; tunperm=beta/&xa; output; end; file print noprint; titlel ‘Adaptive Weighted Least Squares Confidence Intervals’ title2 ‘Search method based on method proposed by ’; title3 ‘Garthwaite, P. H., Biometrics, vol. 52, 1996.’; put ; proc reg data=dgarth outest=dtheta outseb noprint; ; model &y=&xr &xa; data dupdate; ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required