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

Hello SAS community. I have written a PROC SGPLOT code that includes the BLOCK statement generating beautiful graphs. I need to identify the default colors used but confused by the several HLS/RGB/HSV options. I used the default template i.e HTMLBlue. I was wondering if someone can point me to some useful way of identifying the precise colors presented in each block. My code is:

 

PROC SGPLOT DATA = Labs;
BLOCK X = age_weeks BLOCK = PHASES /TRANSPARENCY=0.8 POSITION=CENTER VALUEFITPOLICY=/*NONE | SHRINK |SPLIT*/ SPLIT SPLITCHAR='';
SERIES X = age_weeks Y = cd4_percent / MARKERS MARKERATTRS=(COLOR=BLACK SYMBOL=CIRCLE) LINEATTRS = (COLOR=RED THICKNESS = 2 PATTERN=DASH) LEGENDLABEL = 'CD4 Percent';
XAXIS LABEL = 'Weeks';
YAXIS MIN=30 LABEL = 'CD4 Percent values';
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I'm glad to hear that 🙂 Please let me know if I can help you with anything else. Otherwise, please mark this thread as a solution.

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

You can do like this

 

 

libname temp "C:/temp";
proc template;
source styles.statistical / file='temp.tmp'; /* write template to text file */
quit;
 
data Colors;
keep Name Color R G B;
length Name Color $8;
infile 'temp.tmp';
input;
k = find(_infile_,'gdata','i');/* EDIT: Use gdata instead of gcdata */
if k > 0 then do;
   s = substr(_infile_, k);
   j = index(s, "'");
   Name = substr(s, 1, j-1);
   j = index(s, "=");
   Color = compress(substr(s, j+1));
   R = inputn(substr(Color, 3, 2), "HEX2.");
   G = inputn(substr(Color, 5, 2), "HEX2.");
   B = inputn(substr(Color, 7, 2), "HEX2.");
end;
if k > 0;
run;
 
proc print data=Colors; 
var Name Color R G B;
run;

 

The approach is from What colors does PROC SGPLOT use for markers?. I edited the code a little bit and commented the main change: looking for gdata instead of gcdata in the template file. In the Colors data set, gdata1 is the first color used, gdata2 is number two and so on.

Naviava1973
Fluorite | Level 6

Thank you very much Draycut. This is helpful.

PeterClemmensen
Tourmaline | Level 20

I'm glad to hear that 🙂 Please let me know if I can help you with anything else. Otherwise, please mark this thread as a solution.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

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
  • 3 replies
  • 4023 views
  • 5 likes
  • 2 in conversation