BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pchegoor
Pyrite | Level 9

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;



 

 

 

 

Capture.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

View solution in original post

5 REPLIES 5
pchegoor
Pyrite | Level 9

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.

Rick_SAS
SAS Super FREQ

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;
pchegoor
Pyrite | Level 9

Awesome  @Rick_SAS  .  This is exactly what i wanted.  Thanks.

GraphGuy
Meteorite | Level 14

Here's the output from Rick's solution, for those who would like to see what it looks like:

 

bar_rick.png

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2289 views
  • 4 likes
  • 4 in conversation