Hi
I have created the below graph
My code below:
proc template;
define statgraph bar100;
begingraph / datacolors=(white lightgrey darkgrey grey black) datacontrastcolors= (black black black black black);
layout datalattice columnvar=trt01p /
columns=2 rows=1 columndatarange=union headerlabeldisplay=none /*columnheaders=BOTTOM headerlabeldisplay=value headerlabellocation=inside*/
rowaxisopts=(display=all label='Percentage of Patients' linearopts=(viewmin=0 viewmax=100 tickvaluesequence=(start=0 end=100 increment=10) viewmin=0 viewmax=100 tickvalueformat =pct.))
columnaxisopts=(display=(tickvalues) );
layout prototype / cycleattrs=true;
BARCHARTPARM X = avisit y=percent / group=avalc name="lgnd1" ;
innermargin / align=bottom opaque=true separator=True;
axistable x=avisit value=count/ display=(label) classdisplay=stack class=avalc classorder=descending labelposition=max position=1 pad=1 ;
endinnermargin;
endlayout;
sidebar / align=bottom;
entry halign=center "&trt1 | &trt2 " /opaque=true border=true borderattrs=(color=black) backgroundcolor=lightgrey textattrs=(COLOR=black size=8 ) ;
endsidebar;
sidebar / align=bottom;
discretelegend "lgnd1" /valign=bottom location=outside down=1 sortorder=ASCENDINGFORMATTED title='PGI-S response categories:' ;
endsidebar;
endlayout;
endgraph;
end;
run;
proc sgrender data=g100 template=bar100 ;
run;
At present both left panel and the right panel has the colours on grey scale. How do I Keep the left panel colors as it is and the right panel colors on stack varies from white to red?
Thanks
Since you want different group colors in the right cell, then the group values for those segments have to be different. Else, any legend will be wrong. So, assign the groups in the right cell different values from the left cell (so now you have 10 group levels), and assign the different colors for them in the DATACOLORS option.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.