BookmarkSubscribeRSS Feed
pdiff
Obsidian | Level 7

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.

Bill

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.));

  linecolor='Black';

  cards;

  1.5 64

  3 57

  6 48

  12 29

  24 13

  48 2

  ;

run;

data trial ;

  input x y;

  cards;

  1.5 64

  3 57

  6 48

  12 29

  24 13

  48 2

  ;

run;

proc sgplot  data=trial DATTRMAP=attrib;

  scatter x=x y=y/FILLEDOUTLINEDMARKERS markerattrs=(symbol=circlefilled size=10) group=x ATTRID=Test;

run;


5 REPLIES 5
pdiff
Obsidian | Level 7

Update:

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?

Thanks again,

Bill

Cynthia_sas
SAS Super FREQ

Hi:

  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)

and

SAS(R) 9.4 ODS Graphics: Procedures Guide, Fourth Edition (the top link that shows all the sections)

cynthia

DR_Majeti
Quartz | Level 8

Hi Bill,

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.

Thanks,'

Durga.

Jay54
Meteorite | Level 14

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;

run;

pdiff
Obsidian | Level 7

Sanjay and others,

        Thank you very much for your help with this. Excellent answers as usual.  I will also look into upgrading to TS1M2.

Bill Price

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 5 replies
  • 2241 views
  • 3 likes
  • 4 in conversation