BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OPHD1
Fluorite | Level 6

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
PaigeMiller
Diamond | Level 26

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

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
OPHD1
Fluorite | Level 6

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.

PaigeMiller
Diamond | Level 26

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

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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