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;
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.
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.
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!).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.