06-04-2015 01:28 AM
I am trying to create a plot using sgplot and scatter that will color code data points based on the value of an endogenous variable. I used to do this through SAS Insight, but that is gone. I thought I could do it through attribute maps, but I am getting errors. In the code below I am plotting 6 values (x,y pairs) color coding by the value of x. Is there a better/easier way to do this. Please excuse the rough state of the code.
SAS 9.4 64 bit TS1M1
Windows 7 under Mac Book Pro (Yosemite 10.10.3): Parallels 10.2.1
Thanks for any help on this.
data attrib (drop=x red green blue) ;
format red green blue hex2. ;
length linecolor $8 fillcolor $8;
input @1 x @1 value$ y;
ID = 'Test';
red = int((x/48)*255);
green = 0;
blue=255 - red;
fillcolor= cats('CX',put(red, hex2.),put(green, hex2.),put(blue, hex2.));
data trial ;
input x y;
proc sgplot data=trial DATTRMAP=attrib;
scatter x=x y=y/FILLEDOUTLINEDMARKERS markerattrs=(symbol=circlefilled size=10) group=x ATTRID=Test;
06-04-2015 02:33 AM
I managed to get this to work by:
1) Removing the FILLEDOUTLINEDMARKERS option
2) Changing the attribute variable name "fillcolor" to "MarkerColor".
Is there a list of keyword for attribute map variables?
Also, what if I still wanted outlined markers?
06-06-2015 12:09 PM
There is a section in the ODS Graphics doc for the SG Procedures that discusses Attribute Maps and shows the list of reserved variable names:
SAS(R) 9.4 ODS Graphics: Procedures Guide, Fourth Edition (the specific link with reserved variables)
SAS(R) 9.4 ODS Graphics: Procedures Guide, Fourth Edition (the top link that shows all the sections)
06-07-2015 01:01 AM
Do you have Mock, that will be helpful to us to give correct options can be used.
Yes if you need symbols to present, you have to use markercolor.
06-15-2015 10:18 AM
What you need is a color response based on a variable.
COLORRESPONSE is supported for both SCATTER and BUBBLE starting from SAS 9.4(TS1M2). You are using TS1M1, so that option is not available. However, these options are available in GTL in TS1M1.
An easy way to get started would be to run the SGPLOT procedure as you have, and set TMPLOUT="FileName.sas" SGPLOT will write the generated GTL template program to this file name. Template name will be "SGPLOT". Go to the ScatterPlot statement as add the option MARKERCOLORGRADIENT=variable. You can also use the COLORMODEL option to get the colors you want, or use DISCERTEATTRMAP to get full control on colors and values.
You will need to use the following statement to run the graph from template.
proc sgrender data=foo template=sgplot;