Data visualization with SAS programming

proc sgplot - 9.4 - different marker symbols for grouping but change color based on another variable

Reply
Occasional Contributor
Posts: 11

proc sgplot - 9.4 - different marker symbols for grouping but change color based on another variable

Hello all, I don't have any issues with getting different marker symbols for the group variable; however, I need to change the color of the symbols based on another variable. 

 

I am familiar with the grouplc option, but my version of SAS, which is 9.4, must not be the most up to date version because this option is not recognized.  

 

Is there a different way to achieve this without the grouplc option?

 

Thanks!

Grand Advisor
Posts: 17,325

Re: proc sgplot - 9.4 - different marker symbols for grouping but change color based on another vari

Run the following to identify your version for starters:

 

proc setinit;run;

Have you tried the STYLEATTRS statement in PROC SGPLOT? Can you provide sample data we can work with?

Occasional Contributor
Posts: 11

Re: proc sgplot - 9.4 - different marker symbols for grouping but change color based on another vari

Running your code, for current version it says 9.04.01M3P062415

 

STYLEATTRS  does help with the styling, but I am not sure specifically how I would achieve what I need using it.  Here is a sample data (not real):

 

IDDATEAGEVALUESUPPORT LEVEL
11/1/201610301
11/3/201711352
22/2/201611352
22/5/201712303
35/14/201710361
35/15/201710313

 

x is Age, y is Value, the group is ID but I need the color to be by support level

SAS Super FREQ
Posts: 889

Re: proc sgplot - 9.4 - different marker symbols for grouping but change color based on another vari

Is the coloring variable continuous or discrete?

Occasional Contributor
Posts: 11

Re: proc sgplot - 9.4 - different marker symbols for grouping but change color based on another vari

I don't believe it to be continuous.  I used colorresponse and gradlegend in the scatter to switch the coloring to a different variable other than the group.  Now there is a gradient.  As you can see in the sample data above, I don't need a gradient just solid colors, but this is the only way I have found thus far.

 

Thanks!

SAS Super FREQ
Posts: 889

Re: proc sgplot - 9.4 - different marker symbols for grouping but change color based on another vari

If the number of unique combinations between your two class variables is reasonable, you can use an attributes map to bind unique symbol shapes and colors to each crossing. You will need to create a variable that contains unique values that represents each crossing. Here is a blog post that will give you an introduction to attributes maps if you have not used them: http://blogs.sas.com/content/graphicallyspeaking/2012/02/27/roses-are-red-violets-are-blue/

 

Hope this helps!

Dan

Ask a Question
Discussion stats
  • 5 replies
  • 108 views
  • 2 likes
  • 3 in conversation