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

I like the graphs output at baseline from the proc reg command for linear regression:

 

ods graphics on;

proc reg DATA=good;

MODEL mv_glob_ap_diam=BSA/ stb clb;

OUTPUT OUT=OUTREG1 P=PREDICT R=RESID RSTUDENT=RSTUDENT COOKD=COOKD

run;quit;

ods graphics off;

 

Example here:

FitPlot Example.PNG

 

I created many of these graphs for a figure of a paper, but the journal would like more color to differentiate them.  As such I would like to change the points, and possibly the lines and shading to different colors.  Because this is a SAS standard output I am unsure how to do this. 

 

I have tried GOPTIONS prior to the command, but they are trumped by the PROCREG default options.  Specifically I set CPATTERN and CSYMBOL to a Yellow prior to the reg procedure.

 

 

Then I tried to recreate the plot in a more basic way using the plot command and conf, and it contains the correct information but I will need to define all the different parameters that make up the graph, x, y spacing, coloring, etc.

 

ods graphics on;

proc reg DATA=good;

MODEL mv_glob_ap_diam=BSA/ stb clb;

Goptions Csymbol=Red Cpattern=Red;

plot mv_glob_ap_diam*BSA /conf;

run;quit;

ods graphics off;

 

 

 

Using Plot.PNG

 

 

I can try to figure this out, but am unsure to make the 95% confidence interval area shade as opposed to be a line etc, and like the more basic X and Y tick marks and scales in the Fit Plot.

 

Ideally I could use the standard output, but just tell it to use a different color than blue.  Is there a simple way to do that more globally, or do I need to specify plot and individually define everything to recreate the fit plot I like?

 

Is there an example of the underlying fitplot code that I can edit instead of trial and error from scratch?

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
cakemonster
Fluorite | Level 6

Thank you VERY much.

 

I basically want to be able to change the color of the data points, and the shading of the 95% confidence interval between the limit lines, as well as the actual fit line, but leave the rest of the appearance in the "fit plot" the same.

 

I will play with this.  I really appreciate it.  i have to remake ~ 10 graphs and this helps me for the future as well.

View solution in original post

8 REPLIES 8
snoopy369
Barite | Level 11

You can get effectively the same graph using the REG statement in SGPLOT. Then you have tons of control.

 

It's unclear exactly _what_ you want to control, so I'll just change a few things arbitrarily here.

 

Here are two examples: the original one almost identical to yours, and one where I changed almost everything.

 


title "Original";
proc sgplot data=sashelp.class;
reg x=height y=weight / CLM CLI;
run;
 
title "Modified version";
proc sgplot data=sashelp.class;
reg x=height y=weight / CLM CLI lineattrs=(color=green) markerattrs=(color=red) 
clmattrs=(clmfillattrs=(color=blue)) cliattrs=(clilineattrs=(color=orange))
;
run;

 

Original REG.png

 

versus

 

Modfied REG.png

cakemonster
Fluorite | Level 6

Thank you VERY much.

 

I basically want to be able to change the color of the data points, and the shading of the 95% confidence interval between the limit lines, as well as the actual fit line, but leave the rest of the appearance in the "fit plot" the same.

 

I will play with this.  I really appreciate it.  i have to remake ~ 10 graphs and this helps me for the future as well.

cakemonster
Fluorite | Level 6

Can you show me how to make the lines bordering the confidence interval "broken" or dashed as they are in the original image.

 

Thank You.

DanH_sas
SAS Super FREQ

Using snoopy's example:

 

cliattrs=(clilineattrs=(color=orange pattern=dash))
DanH_sas
SAS Super FREQ

Since your just tweaking the appearance for journal submission (as opposed to applying the change in a batch run), your best option is to probably use the ODS Graphics editor. On the ODS destination statement (HTML, in the case), add SGE=on to the statement:

 

ods html sge=on;;

ods graphics on;

proc reg DATA=good;

MODEL mv_glob_ap_diam=BSA/ stb clb;

OUTPUT OUT=OUTREG1 P=PREDICT R=RESID RSTUDENT=RSTUDENT COOKD=COOKD

run;quit;

ods graphics off;

 

You should see an addition node appear in the results viewer. Double-click on it, and the editor will appear with your graph. It is a "live" graph, so you can do things like:

  • Change plot attributes
  • Move legends around
  • Edit titles/footnote/axis label
  • Annotate the graph

You cannot edit the data, though (that is by design). Give that try and see if it does everything you need.

 

Thanks!
Dan

cakemonster
Fluorite | Level 6

I will try this as well.  Thank you.

snoopy369
Barite | Level 11

The other option you have, by the way, if you're preferring to stay within PROC REG, is to change the styles in your current style template.  This is covered in great detail here: https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_odsgraph_se...

 

This is the "new" way to do what you were trying to do with GOPTIONS, which I don't think has any effect on ODS GRAPHICS but only works on old-style graphics.

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