BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
michelconn
Quartz | Level 8

I am running proc loess and would like the dots to be different colors based on a variable. The variable values are A, B, or C and I want the dots to be a specific color depending on if they are A, B, or C. I would still like all the data to remain on the same graph. I would also like a legend. I couldn't find the option within proc loess so I was hoping maybe there was a global option or format that could do it. 

 

Thanks

 

SAS 9.4

 

proc loess data=Veh_All_Ramp1_106 plots(only)=fit;
	model speed=distance / smooth=0.5;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The easiest way to accomplish this is to use PROC SGPLOT and overlay a loess curve on top of a scatter plot with the GROUP= option.

 

proc sgplot data=sashelp.cars(obs=100);
scatter x=weight y=mpg_city / group=origin markerattrs=(symbol=CircleFilled);
loess x=weight y=mpg_city / smooth=0.5 nomarkers;
run;

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

The easiest way to accomplish this is to use PROC SGPLOT and overlay a loess curve on top of a scatter plot with the GROUP= option.

 

proc sgplot data=sashelp.cars(obs=100);
scatter x=weight y=mpg_city / group=origin markerattrs=(symbol=CircleFilled);
loess x=weight y=mpg_city / smooth=0.5 nomarkers;
run;
PGStats
Opal | Level 21

Here is an example using sashelp.class:

 

proc sgplot data=sashelp.class;
loess x=height y=weight / nomarkers smooth=0.5;
scatter x=height y=weight / group=sex markerattrs=(symbol=circlefilled);
run;

SGPlot2.png

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 928 views
  • 2 likes
  • 3 in conversation