BookmarkSubscribeRSS Feed
Prankerd
Calcite | Level 5

Hey all.

I am a very beginner at statistics and SAS program and have difficulties in presenting my study.

 

I would like to make a graph: x=years, y= "adjusted" Odds Ratio (reference": year1 data) and a band of 95%confidence intervals.

I read some manuals and blogs but kept failing it.

 

I don't know how to set "years1 data" as my reference, and why my graph is jagged after covariate adjustment.

here are my codes and graph. 

Many thanks.

 

 

PROC SORT DATA=CM.POSTMP OUT=TEST;
BY WITH6; RUN; /*WITH6 is my independent variable(years)*/
ods select ANOVA ParameterEstimates SplineKnots; proc LOGISTIC data=TEST; effect spl = spline(WITH6/ NATURALCUBIC details basis=tpf(noint) ); CLASS EDU_GR(REF='1') MARRIAGE_GR(REF='1') WORK_GR(REF='0') INCOME_Q(REF='1') SMOKE_GR(REF='0') ALCOHOL_GR(REF='0') MET_GP(REF='1') B12(REF='1') /PARAM=REF; model HTN_SYS(EVENT="1")= spl AGE EDU_GR MARRIAGE_GR WORK_GR INCOME_Q SMOKE_GR ALCOHOL_GR MET_GP BMI B12 / selection=none; /*HTN_sys is binary*/ output out=SplineOut predicted=Fit; quit; title "Restricted Cubic Spline Regression"; proc sgplot data=SplineOut noautolegend; scatter x=WITH6 y=HTN_SYS; series x=WITH6 y=Fit / lineattrs=(thickness=2 color=red); run;

Prankerd_0-1633596850379.png

 

 

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Yes,  this occurs because of the covariates in the model, as explained in the article, "Visualize multivariate regression models by slicing continuous variables."

 

The same article shows how to fix this problem. Basically, you do not want to use the SplineOut data set. Instead, you want to construct a data set that has a range of WITH6 values and uses a specified constant for the other covariates. Generally, the mean is used for the continuous variables, such as Age, and reference levels are used for the classification variables.

 

For many models, you can use the EFFECTPLOT statement in the procedure or in PROC PLM for this. However, it might be that spline effects are not supported in the EFFECTPLOT statement. In that case, you can construct the scoring data yourself, as shown in the article, "How to create a sliced fit plot in SAS."

 

StatDave
SAS Super FREQ

To plot the probability of the event against your WITH6 variable, just add an EFFECPLOT statement in your PROC LOGISTIC step:

effectplot fit(x=with6);

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 743 views
  • 6 likes
  • 3 in conversation