BookmarkSubscribeRSS Feed
sassy7
Obsidian | Level 7

Hello,

My question involves colors definition in a proc template for producting a clustered bars chart.
Bars represent products while clusters represent years: each product has its own color and the graph shows the sales of some products across several years.

In the past, I used HEX colors coding for several SAS graphs using proc sgplot with excellent results.
Some examples of HEX color coding used in the past are: "#C95117" (red) or "#FAD500" (yellow).

When I tried to use the hex color coding scheme in proc template I received an error message,
while using the SAS color scheme the procedure runs fine.

The client has a company color coding and wants the graphs to be aligned with that, so here is my question:
which color coding should be used with proc template: SAS , HEX, RGB or others?
Also, in the proc template I defined colors in the following way:

proc template ...;
......
begingraph/ datacolors=(green yellow red) datacontrastcolors=(green yellow red);
....
run;

Is there another way to define colors used by a bar chart in proc template?

Greeting,

2 REPLIES 2
DanH_sas
SAS Super FREQ

Use "cx" Instead of using "#" as the RGB indicator (e.g. "#C95117" (red) or "#FAD500" (yellow) becomes "cxC95117" (red) or "cxFAD500" (yellow). The "cx" indicator is standard in SAS for specifying RGB color values.

 

Hope this helps!

Dan

ballardw
Super User

SAS will accept several different color schemes and the method for the codes varies by the prefix as well as the color scheme. I haven't run into an instance where mixing the schemes in a single use causes problems as long as the code is correct.

From the documentation:

Overview of Color-Naming Schemes

The valid color-naming schemes in SAS are as follows:
  • RGB (red green blue)
  • RGBA (red green blue transparency)
  • CMYK (cyan magenta yellow black)
  • HLS (hue lightness saturation)
  • HSV (hue saturation brightness), also called HSB
  • Gray scale
  • SAS color names (from the SAS Registry)
  • SAS Color Naming System (CNS)
Examples of SAS Color-Naming Schemes shows examples of each color-naming scheme.
Examples of SAS Color-Naming Schemes
Color-Naming Scheme
Example
RGB
COLORS=(CX98FB98 CXDDA0DD CXFFDAB9 CXDB7093 CXB0E0E6)
RGBA
COLORS=(A98FB9833 ADDA0DD66 AFFDAB999 ADB7093CC AB0E0E6FF)
Note: The RGBA color mode is not supported by Java devices. The RGBA color mode is supported by ActiveX devices when the output is used in Microsoft applications.
CMYK
COLORS=("FF00FF00" "00FFFF00" "FFFFFF00")
HLS
COLORS=(H14055FF H0F060FF H0B485FF H07880FF)
HSV
COLORS=(V0F055FF V010FFFF V03BFFFF V12C55E8)
Gray Scale
COLORS=(GRAY4F GRAY6D GRAY8A GRAYC3)
SAS Registry Colors
COLORS=(palegreen plum peachpuff palevioletred powderblue)
CNS Color Names
COLORS=("very light purplish blue" 
"light vivid green" "medium strong yellow" 
"dark grayish green")

 

Also if you have the value of one scheme and need the equivalent in another SAS provides some macros to help if you have SAS/Graph:

conversions that are possible using these macros.
From Color Value
To Color Value
Conversion Macro
CMY
RGB
%CMY
CNS
HLS
%CNS
RGB
HLS
%RGB2HLS
HLS
RGB
%HLS2RGB

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1239 views
  • 4 likes
  • 3 in conversation