BookmarkSubscribeRSS Feed
Ani7
Obsidian | Level 7

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?

 

3 REPLIES 3
Ksharp
Super User

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;

 

Ksharp_0-1659867529208.png

 

Ani7
Obsidian | Level 7

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;

Ani7_0-1659900479872.png

 

 

Ksharp
Super User

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;

Ksharp_0-1659959483652.png

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—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
  • 3 replies
  • 1645 views
  • 0 likes
  • 2 in conversation