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
There are a number of possibilities for doing this, depending on your version of SAS. What version of SAS do you have?
We currently use 9.1.3. Trying to talk them into defaulting to 9.2 but haven't been successful so far.
--Ben
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.