## Available RGB colors in SAS

Hi all,

I'm familiar with converting RBG to Hex colors via the %colormac macro.

Here is the code I use to output the appropriate SAS colors. However, when I graph them it is clear it is not the correct colors. They are supposed to vary from yellow to red for the first six colors, and the last color is a standard grey. However, in some cases, the same color is output for multiple inputs (yellow and grey in this example). Is it possible to use exactly these colors in SAS?

%colormac;

data _null_;

%put %rgb (225, 210, 130) ; *this is a yellow;

%put %rgb(253,185,39); *this is a darker yellow;

%put %rgb(225,130,37); *this is a light orange;

%put %rgb(202, 82, 32); *this is a deeper orange;

%put %rgb(181, 18, 27); *this is a light-medium red;

%put %rgb(141, 27, 29); *this is a deeper red;

%put %rgb(191, 191, 191); *this is grey;

run;

For grey and the first yellow, it outputs CXFFFFFF for both, which makes me wonder about the possible RGB color range.

Can these exact colors be used?

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Available RGB colors in SAS

The documentation says that the RGB values must be in the range from 0 to 100, so your commands are obviously incorrect.

--
Paige Miller
3 REPLIES 3

## Re: Available RGB colors in SAS

The documentation says that the RGB values must be in the range from 0 to 100, so your commands are obviously incorrect.

--
Paige Miller

## Re: Available RGB colors in SAS

Thanks Paige. SAS needs 0-100 set of RGB.

Both the 0-100 and 0-255 sets of sRGB data represent the same sRGB standard. Notation in the 0-100 scale simply uses percentages of the 0-255 scale.

sRGB 0-255: 237-233-140.

To calculate the 0-100 value, simply use the absolute value of the decimal equivalent of the percentage of 255 contained in the 0-255 value, as follows:

R 237 = 237/255 = .929 rounded to .93; Absolute value of .93 = 93

G 235 = 237/255 = .909 rounded to .91; Absolute value of .91 = 91

B 140 = 140/255 = .549 rounded to .55; Absolute value of .55 = 55.

The resulting 0-100 value is 93-91-55.

We hope that you find this explanation helpful.

## Re: Available RGB colors in SAS

As far as I know, rounding isn't necessary to use the %RGB macro.

--
Paige Miller
Discussion stats
• 3 replies
• 1112 views
• 0 likes
• 2 in conversation