I want to use bcd4=1 as the reference level, but there is Error 22-322 and I would like someone to help with it, thank you! data workdata;set workdata;
if LBDBCDSI<=1.78 then bcd4=1;
if 1.78<LBDBCDSI<=3.56 then bcd4=2;
if 3.56<LBDBCDSI<=6.23 then bcd4=3;
if 6.23<LBDBCDSI then bcd4=4;
run;
proc univariate data=workdata2; var urine_cd; weight WTSHM6YR;run; /* take down the min, 25%, 50%, 75%, and the max value. */
data workdata2;set workdata2;
if urine_cd<=1.38 then ucd4=1;
if 1.38<urine_cd<=2.69 then ucd4=2;
if 2.69<urine_cd<=5.09 then ucd4=3;
if 5.09<urine_cd then ucd4=4;
run;
/* fit data by using restricted cubic splines */
ods select ANOVA ParameterEstimates SplineKnots;
proc glmselect data=workdata;
effect spl = spline(RIDAGEYR / details naturalcubic basis=tpf(noint)
knotmethod=percentiles(5) );
model LBDBCDSI = spl / selection=none; /* fit model by using spline effects */
output out=SplineOut predicted=Fit; /* output predicted values for graphing */
quit;
title "Restricted Cubic Spline Regression";
proc sgplot data=SplineOut noautolegend;
scatter x=RIDAGEYR y=LBDBCDSI;
series x=RIDAGEYR y=Fit / lineattrs=(thickness=3 color=red);
run;
/*model_1*/
data workdata;set workdata;/*years modeled as restricted cubic spline with 5 knots*/
if RIDAGEYR<=30 then age=1;
if 30<RIDAGEYR<=40 then age=2;
if 40<RIDAGEYR<=49 then age=3;
if 49<RIDAGEYR<=61 then age=4;
if 61<RIDAGEYR<=71 then age=5;
if 71<RIDAGEYR then age=6;
run;
data workdata;set workdata;/*education*/
if DMDEDUC=1 then edu=1;
if DMDEDUC=2 then edu=2;
if DMDEDUC=3 then edu=3;
run;
data workdata;set workdata;/*race*/
if RIDRETH1=3 then race=0;
else if RIDRETH1=4 then race=1;
else if RIDRETH1=1 then race=2;
else race=3;
run;
/*linear regression-model1-blood cd*/
proc surveyreg data=workdata;
class bcd4 (ref='1') age RIAGENDR race edu;
model BPXSAR=bcd4 age RIAGENDR race edu/ vadjust=none;
stratum sdmvstra;
cluster sdmvpsu;
weight wtmec6yr;
run;
... View more