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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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