BookmarkSubscribeRSS Feed
sarobinson010
Calcite | Level 5

Dear SAS users,

 

I am using SAS Enterprise Guide to look at the relationship between online patient portal use (continuous; X) and age (continuous; Y), and whether this relationship differs by dichotomous variable region (M; categorical; rural or urban).This patient portal data (X) is not normally distributed, so I am trying to fit a loess curve. I would like to overlay 1 loess curve for rural and one curve for urban on the same graph. My data are set up as such:

 

PortalUse        Region        Age
3                Rural         45
7                Urban         67
2                Urban         83
etc...

Right now, I have only figured out how to plot separate loess curves (one plot for rural, one for urban) with the following syntax:

 

ods graphics on;
ods select FitPlot;
proc loess data=LoessData plots=FitPlot;
by region;
model Age = PortalUse / interp=linear degree=1 select=AICC(presearch); run;

 Is there a way to graph these two loess curves on the same plot? ideally, it would look  something like this (with obvious differences in the x and y axes labels):

 

Image result for multiple lines one loess graph

 

Thank you in advance for your expertise and time.

 

Stephanie

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Easily done via PROC SGPLOT.

 

Use two LOESS commands in your PROC SGPLOT.

--
Paige Miller
PGStats
Opal | Level 21

Use BY processing and SGPLOT. Example:

 

proc sort data=sashelp.heart out=heart; by sex height; run;

proc loess data=heart plots=none;
by sex;
model weight = height / interp=linear degree=1;
output out=smooth predicted=smWeight;
run;

proc sgplot data=smooth;
where ageAtStart between 60 and 65;
scatter x=height y=weight / group=sex markerattrs=(symbol=circle);
series x=height y=smWeight / group=sex lineattrs=(pattern=solid);
run;

SGPlot3.png

 

PG
PaigeMiller
Diamond | Level 26

Yes, @PGStats, that fits better than my answer above.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1991 views
  • 0 likes
  • 3 in conversation