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;
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.
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.
Thank you very much Draycut. This is helpful.
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.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: