BookmarkSubscribeRSS Feed
BenConner
Pyrite | Level 9

Hi,

Is there a way to assign specific colors to values in a 2 or 3 d chart?  I have counts by month by year. Years tend to vary within a modest range. I'd like to make the same year the same color across any given graph.

It seems like this would be a parameter within an Axis statement, but I didn't see anything obvious.

Thanks!

--Ben

3 REPLIES 3
DanH_sas
SAS Super FREQ

There are a number of possibilities for doing this, depending on your version of SAS. What version of SAS do you have?

BenConner
Pyrite | Level 9

We currently use 9.1.3.  Trying to talk them into defaulting to 9.2 but haven't been successful so far.

--Ben

DanH_sas
SAS Super FREQ

For 9.1.3, your choices will definitely be more limited. For 3-D scatterplots, you can use PROC G3D and the SCATTER statement. On this statement, there are three visual options that take either literal values or variables: COLOR, SHAPE, and SIZE. You can use a datastep to encode these attributes into different columns based on a criteria in your datastep. Then, assign those variables using those SCATTER options. Other than this procedure, I do not know of another reliable way of making attribute assignments at 9.1.3

In 9.2, the Graph Template Language (GTL) has a plot option called INDEX which takes a variable that is an index to an ODS style element. This index variable is usually created using criteria in a datastep, similar to the previous idea. This option is available on most plot statements that support GROUP variables.

In 9.3, both GTL and the SG procedures have true attribute map capabilities. These attributes maps give the ability to assign visual attributes (fill/line/marker colors, line patterns and marker shapes) to data values, and these attributes are applied to the data values regardless of data order. The input data does not have to be processed in a datastep as in the the previous two examples. GTL also the ability to create attribute maps for continuous ranges. If you have not upgraded yet, version 9.3 is probably the best version to accomplish what you want.

Hope this helps!

Dan

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 889 views
  • 0 likes
  • 2 in conversation