Hi,
Is there a way to customize the standard plots that are produced using PROC REG ? For example, is there a way I can color code ( on the basis of group), enlarged the circles or change the shape of the symbol in this fit plot?
Dummy Data:
Group Xaxis Yaxis
1 10 5
1 20 10
1 30 15
2 40 20
2 50 25
3 60 30
3 70 35
3 80 40
Yes, but not easily.
It's done via modifying the graph template.
Warren Kuhfeld has a few papers as well as a video that details the steps.
The other option is to get the raw data and create the plot manually using either SGPLOT or GTL.
Maybe see this example:
SG Procs offer a lot of options for customization.
An attribute map is the easiest way.
Full write up:
You haven't specified a SAS version, I'm assuming 9.4
The Procs have changed a lot in the last versions.
Three ways, depending on your needs and programming experience. A nice overview is the paper by Rodriguez.
1. ODS Graphics Editor for tiny changes (titles, lines,...)
2. Use the OUTPUT statement to generate the data you want, then use PROC SGPLOT to create the graph with the attributes you want.
3. Create an ODS style or modify the templates. See "ODS Graphics" chapter in the SAS/STAT documentation.
Personally, I recommend (2) for your needs, since it sounds like you don't have much experience with ODS styles or templates. There are many papers that introduce SG procedures like SGPLOT. Here's an introductory paper on SG procedures that I encountered recently.
Thanks I did some work around and was able to get this plots. But getting stuck in assigning different symbols for example, triangle for Normal, circle for moderate and square for mild. Is there a quick fix?
That depends. You should post your code, otherwise we don't know if you used GPLOT or SGPLOT or GTL or modified the template...
Thanks below is the code. I have SAS 9.2
proc sgplot data=plot_data ;
reg x=&xaxis y=&yaxis / CLM CLI markerattrs=(color=white) name="reglegend";
inset "R-Squared: %cmpres(&rsq_3sig)" /noborder ;
scatter x=&xaxis y=&yaxis/ group = cohort_no markerattrs=(symbol=circlefilled size=10px) name="scatterlegend" ;
footnote height=1 justify=center "P-Value: %cmpres(&pvalue)" ;
keylegend "reglegend" / position = bottom location = outside;
keylegend "scatterlegend"/ position = topright location = inside down=3 noborder ;
&xaxis = "&xlabel";
run;
Have you tried the symbol option on markerattrs?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.