BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
andrealivraghi
Calcite | Level 5

 

%macro scatter (x,y, xlabel, ylabel, pearson, pval);

ods html gpath = '...';
ods graphics / reset = all width = 12in height = 6in border = off
imagename = "Scatter_&x-&y" imagefmt = png ;

proc sgscatter data = data_2015;
plot &x*&y /  filledoutlinedmarkers group = type 

markerfillattrs = (color = CX62C0FF) 
markeroutlineattrs = (color = CX265C7F  thickness = 1)
markerattrs = (symbol = circlefilled size = 15 )

/* Here i want to include two more colors */ ; title "Pearson = &pearson P-Value = &pval"; label &x = "&xlabel" &y = "&ylabel"; run;

Hi everyone, 

 

I am trying to specify 3 different markers colors in a gscatter procedure according to a categorical variable "type" (assuming 3 values) specified in the group option. How can I use the filledoutlinedmarkers option for grouped variables in the same scatterplot?

 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

There are two way to do this. One way is to just override the style colors using the DATACOLORS and DATACONTRASTCOLORS option:

 

proc sgscatter data=sashelp.class datacolors=(lightblue pink) datacontrastcolors=(blue maroon);
plot weight*height / group=sex filledoutlinedmarkers
markerattrs=(symbol=circlefilled size=10);
run;

You can also use a discrete attributes map to associate the colors to the correct group values so that you are not dependent on data order:

 

data markermap;
retain id "myid";
length fillcolor $ 9 markercolor $ 6;
input value $ fillcolor $ markercolor $;
cards;
F pink      maroon
M lightblue blue
;
run;

proc sgscatter data=sashelp.class dattrmap=markermap;
plot weight*height / group=sex attrid=myid filledoutlinedmarkers
markerattrs=(symbol=circlefilled);
run;

Hope this helps!

Dan

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

There are two way to do this. One way is to just override the style colors using the DATACOLORS and DATACONTRASTCOLORS option:

 

proc sgscatter data=sashelp.class datacolors=(lightblue pink) datacontrastcolors=(blue maroon);
plot weight*height / group=sex filledoutlinedmarkers
markerattrs=(symbol=circlefilled size=10);
run;

You can also use a discrete attributes map to associate the colors to the correct group values so that you are not dependent on data order:

 

data markermap;
retain id "myid";
length fillcolor $ 9 markercolor $ 6;
input value $ fillcolor $ markercolor $;
cards;
F pink      maroon
M lightblue blue
;
run;

proc sgscatter data=sashelp.class dattrmap=markermap;
plot weight*height / group=sex attrid=myid filledoutlinedmarkers
markerattrs=(symbol=circlefilled);
run;

Hope this helps!

Dan

andrealivraghi
Calcite | Level 5
Thank you! Both solutions work fine

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2039 views
  • 0 likes
  • 2 in conversation