I have a proc template within a macro. The data is subset based on the value of VAR (if VAR = 1, or 2, or 3, etc.) This produces a 5-page bar graph with one VAR group on each page. The bars are the same color on each page (red), but I want them to be different colors.
I've read some similar threads in this group, which included using DATACONTRASTCOLORS, but that apparently doesn't work in 9.2 as I got an error when I added it. I need to make the value of the color a macro variable, so I can change it with each call of the macro.
Is there some way to force bar colors in 9.2?
You really should show the code for the template, assuming that is a template used by SGrender. If you are using another procedure such as SGplot or Sgpanel show that code. With 9.2 you may want to move to Sgrender to have more control.
A little example data may help as well.
If using Sgrender a dynamic variable to pass the color to the template would work.
You should be able to use GROUP=VAR in the VBAR statement. Also set UNIFORM=GROUP in the proc statement. This will make all bars in one graph with BY=VAR.
ods _all_ close;
ods html;
proc sort data=sashelp.class out=class;
by sex;
run;
proc sgplot data=class uniform=group;
by sex;
vbar name / response=height group=sex;
run;
ods html close;
With GTL, you can use the INDEX= option. Create a new column "Index" with values 1 for Males and 2 for Females. Then set INDEX=index on the BarChart statement.
Thanks for the input, everyone!
First, the code belongs to my client and I'm not able to share a lot of detail--just the overall logic.
Second, this isn't even my project; I just jumped in to help and now my curiousity has gotten the best of me. 😉
The output is 6 pages. Page 1 is a waterfall all 5 values of VAR, each a different color:
VAR = 1 then red
VAR = 2 then blue
VAR = 3 then yellow
VAR-= 4 then green
VAR = 5 then purple
Pages 2 through 6 are 1 VAR each, and we want the colors to match what is on page 1; so page 2 (VAR = 1) will be red, page 3 (VAR = 2) will be blue, etc.
It seems that the overall issue is how the macros are set up:
I think what we might need to do is find a way to alter that final macro so that we can create each page in a different style, THEN combine them.
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!
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: