Hi
I have the following code to create the attaced graph
proc template;
define statgraph bar100;
begingraph ;
layout overlay/ xaxisopts=(display=standard label=" "
discreteopts=(tickdisplaylist=(&xticks) tickvaluefitpolicy=split tickvaluesplitchar="~") )
yaxisopts=(display=standard label='Percentage of Patients' linearopts=(viewmin=0 viewmax=100 tickvaluesequence=(start=0 end=100 increment=10) viewmin=0 viewmax=100 tickvalueformat =pct.));
BARCHARTPARM X = avisn y=percent / group=avalx name="lgnd1" ;
discretelegend "lgnd1" /halign=right across=1 sortorder=DESCENDINGFORMATTED;
endlayout;
endgraph;
end;
run;
proc sgrender data=all template=bar100;
run;
My Query is how to make the custom colours for the stacks?
I tried using
Begingraph //datacolors=(grey pink lightblue blue orange yellow lightred red lightgreen green black)
This gave me the colours i mentioned but not as the way i wanted. This pics the colours based on the first xaxis value and so on. I tried sorting data using my group variable avalx but that make the graph wrong.
My output without using the datacolours is below:
My intention is to give grey = 00 pink=02 lightblue=04 blue=08 orange=12 yellow=16 lightred=20 red=24 lightgreen=32 green=48 black=ND
Have you considered using a DATTRMAP data set? The data set contains formatted values of your variable and appearance settings.
With SGRENDER
Requirements | Do either one of the following:
|
The values in the DATTRMAP data set must be sorted by ID. If they are not, only the first value is found. |
But I see these are for individual bars and not the stacks within each bars. It is a stacked bar chart .May be I'm missing something?
DATTRMAPS will work for your stacked bar chart as well, as the attribute mapping is tied to your GROUP values. See pages 9-14 in this paper for more information: https://support.sas.com/resources/papers/proceedings17/SAS0675-2017.pdf
Hope this helps!
Dan
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.