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-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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
  • 2 replies
  • 893 views
  • 0 likes
  • 2 in conversation