Data visualization with SAS programming

Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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.


Accepted Solutions
Solution
‎12-08-2016 05:44 PM
Occasional Contributor
Posts: 5

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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


All Replies
Regular Contributor
Posts: 244

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

[ Edited ]

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

Solution
‎12-08-2016 05:44 PM
Occasional Contributor
Posts: 5

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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.

Occasional Contributor
Posts: 5

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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.

SAS Super FREQ
Posts: 889

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

Using snoopy's example:

 

cliattrs=(clilineattrs=(color=orange pattern=dash))
SAS Super FREQ
Posts: 889

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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

Occasional Contributor
Posts: 5

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

I will try this as well.  Thank you.

Regular Contributor
Posts: 244

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

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.

Occasional Contributor
Posts: 5

Re: Changing Colors on a Standard Output FitPlot from ProcReg, or recreating it in PLOT

Thank you.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 242 views
  • 2 likes
  • 3 in conversation