Is there a way to display even a 0 value of Category variable inside a stacked Bar graph?
For eg in the graph image below the first Bar on the left does not display the 0% value for category : AHoldPerc . But i want to display it as 0% . How is this possible?
@DanH_sas , @Jay54 , @GraphGuy : Any suggestions? Thanks
Here is the SAS code for the Image :
Data Sample;
Infile Datalines TRUNCOVER;
Input Category $10. Per percent7.2 Event_Date ddmmyy10.;
format Event_Date date9. Per percent7.2;
Datalines;
ATTPerc 67.16% 25/09/2017
AHoldPerc 0% 25/09/2017
ACWPerc 32.84% 25/09/2017
ATTPerc 68.25% 26/09/2017
AHoldPerc 12.18% 26/09/2017
ACWPerc 19.57% 26/09/2017
ATTPerc 68.11% 27/09/2017
AHoldPerc 12.57% 27/09/2017
ACWPerc 19.32% 27/09/2017
ATTPerc 67.87% 28/09/2017
AHoldPerc 11.28% 28/09/2017
ACWPerc 20.84% 28/09/2017
ATTPerc 69.01% 29/09/2017
AHoldPerc 12.09% 29/09/2017
ACWPerc 18.90% 29/09/2017
ATTPerc 67.98% 2/10/2017
AHoldPerc 11.91% 2/10/2017
ACWPerc 20.12% 2/10/2017
;
Run;
proc sgplot data=sample;
vbar EVENT_DATE / response=Per Group=Category datalabel seglabel;
YAXIS max=1 grid Label="Percentage" Values=(0 to 1 by .05) ;
run;
Use SEGLABELFITPOLICY=NONE. For thin bars (close to zero width), you might also want to use the NOOUTLINE option, which I think makes thin bars easier to see.
proc sgplot data=sample;
vbar EVENT_DATE / response=Per Group=Category datalabel seglabel nooutline SEGLABELFITPOLICY=NONE;
YAXIS max=1 grid Label="Percentage" Values=(0 to 1 by .05) ;
run;
Perhaps you just want to add a data table to your graphic?
Check out this question:
Thanks Tom, But i want to avoid the adding of the table below the graph. But it is nice to know there is an option to do that too.
Use SEGLABELFITPOLICY=NONE. For thin bars (close to zero width), you might also want to use the NOOUTLINE option, which I think makes thin bars easier to see.
proc sgplot data=sample;
vbar EVENT_DATE / response=Per Group=Category datalabel seglabel nooutline SEGLABELFITPOLICY=NONE;
YAXIS max=1 grid Label="Percentage" Values=(0 to 1 by .05) ;
run;
Awesome @Rick_SAS . This is exactly what i wanted. Thanks.
Here's the output from Rick's solution, for those who would like to see what it looks like:
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.