Data visualization with SAS programming

Assigning colors to values in a 2 or 3 d chart

Reply
Regular Contributor
Posts: 179

Assigning colors to values in a 2 or 3 d chart

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

SAS Super FREQ
Posts: 925

Assigning colors to values in a 2 or 3 d chart

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

Regular Contributor
Posts: 179

Assigning colors to values in a 2 or 3 d chart

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

--Ben

SAS Super FREQ
Posts: 925

Assigning colors to values in a 2 or 3 d chart

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

Ask a Question
Discussion stats
  • 3 replies
  • 171 views
  • 0 likes
  • 2 in conversation