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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.