I am trying to use a dattrmap to specify colors for each group of a scatter plot. I specifically need the "filledoutlinemarkers" style but can't seem to figure out if that's possible with the attribute map. The plot that I need can be created like this:
proc sgplot data=sashelp.class ;
scatter x=height y=weight/group=sex filledoutlinedmarkers markerattrs=(symbol =circlefilled);
run;
When I try to make this plot using a dattrmap however, I don't end up having that outline on my markers (just solid filled circles)
data myattrmap;
length id $10. value $30. MARKERCOLOR $40. color $10.;
id = "scatter1";
value='M';
MARKERCOLOR='cxCC7BA1';
MARKERSYMBOL = 'circlefilled';
output;
ID='scatter1';
value="F";
MARKERCOLOR='cx95BDE1';
MARKERSYMBOL = 'circlefilled';
output;
run;
proc sgplot data=sashelp.class dattrmap=myattrmap;
scatter x=height y=weight/group=sex attrid=scatter1;
run;
Is there a way to specify the outline using a dattrmap?
No need " dattrmap= " .
data myattrmap;
length id $10. value $30. MARKERCOLOR $40. color $10.;
id = "scatter1";
value='M';
MARKERCOLOR='cxCC7BA1';
markersize=20;
MARKERSYMBOL = 'circlefilled';
output;
ID='scatter1';
value="F";
MARKERCOLOR='cx95BDE1';
markersize=20;
MARKERSYMBOL = 'circlefilled';
output;
run;
proc sgplot data=sashelp.class dattrmap=myattrmap;
styleattrs datacolors=( cxCC7BA1 cx95BDE1) datacontrastcolors=(red yellow) ;
scatter x=height y=weight/group=sex filledoutlinedmarkers attrid=scatter1;
run;
I can't use this solution since it overrides the dattrmap. So if I plot after filtering to sex="F", I end up with that group being assigned the color for "M" when both "M" and "F" are available.
data myattrmap;
length id $10. value $30. MARKERCOLOR $40. color $10.;
id = "scatter1";
value='M';
MARKERCOLOR='cxCC7BA1';
MARKERSYMBOL = 'circlefilled';
output;
ID='scatter1';
value="F";
MARKERCOLOR='cx95BDE1';
MARKERSYMBOL = 'circlefilled';
output;
run;
proc sgplot data=sashelp.class (where=(sex = "F")) dattrmap=myattrmap;
styleattrs datacolors=(cxCC7BA1 cx95BDE1) datacontrastcolors=(red yellow);
scatter x=height y=weight/group=sex filledoutlinedmarkers attrid=scatter1;
run;
OK。How about this one ?
data myattrmap;
length id $10. value $30. MARKERCOLOR $40.;
id = "scatter1";
value='M';
MARKERCOLOR='cxCC7BA1';
FillColor='cxCC7BA1';
LineColor='green';
MARKERSYMBOL = 'circlefilled';markersize=20;
output;
ID='scatter1';
value="F";
MARKERCOLOR='cx95BDE1';
FillColor='cx95BDE1';
LineColor='black';
MARKERSYMBOL = 'circlefilled';markersize=20;
output;
run;
proc sgplot data=sashelp.class (where=(sex = "F")) dattrmap=myattrmap;
scatter x=height y=weight/group=sex filledoutlinedmarkers attrid=scatter1;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.