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

Dear all,

 

I would like to add colors to my regression plot. I plotted the regression of proportion of protein consumed in the morning with total amount of protein consumed. What I would like to do is give observations belonging to males and females different colours. Does someone have suggestions where I must add this information in my syntax (see below).


Many thanks in advance.

 

proc template;

define statgraph propprotbytotprot;

begingraph;

entrytitle "Proportion of protein ingested during morning by total protein ingested";

layout overlay /xaxisopts=(griddisplay=on)yaxisopts=(griddisplay=on);

modelband "cli" / name="mb1" legendlabel="95% Predict" datatransparency=0.5;

modelband "clm" / name="mb2" legendlabel="95% Mean";

regressionplot x=prop_sum_prot y=prot_day / cli="cli" clm="clm";

scatterplot x=prop_sum_prot y=prot_day;

discretelegend "mb1" "mb2" / border=true across=1 valign=bottom halign=right location=inside;

entry halign=left " Nobs=" eval(strip(put(n(prot_day),12.0))) / valign=top;

endlayout;

endgraph;

end;

run;

proc sgrender data=final.hour template=propprotbytotprot ;

label prop_sum_prot="Proportion of protein ingested during morning hours (g)";

label prot_day="Total protein (g)";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

If you want to use different marker attributes for markers in the scatter plot, add

GROUP=sex 

to the SCATTERPLOT statement, where 'sex' is the name of a categorical variable (might be 'gender'...)

 

The colors/symbols that appear are determined by the current style for the ODS destination.  If you don't like the style choice, you can use a different style or define a discrete attribute map that overrides the style.

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

If you want to use different marker attributes for markers in the scatter plot, add

GROUP=sex 

to the SCATTERPLOT statement, where 'sex' is the name of a categorical variable (might be 'gender'...)

 

The colors/symbols that appear are determined by the current style for the ODS destination.  If you don't like the style choice, you can use a different style or define a discrete attribute map that overrides the style.

teuni
Calcite | Level 5

Hi Rick,

 

Thank you so much for your fast response. I tried this before, but instead of adding group=sex behind the scatterplot statement, I added it behind the regression statement. This did not work out well (obviously!).

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1500 views
  • 0 likes
  • 2 in conversation