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

Hi,

I can't really get the right options to display my desired graph using SGPLOT. 

Code producing the below.

 

1. I want the value to be displayed on top of each bar ( in red)

2. I want to hide the values along the xaxis (highlighted in yellow)

The legend needs to be displayed at the bottom

 

YNWA1_0-1630624958526.png

 

data plot_graph;
infile datalines dlm=",";
input Exception $22. tot_pcnt;
datalines;
Tot_Number_Exception_A,2
Tot_Number_Exception_B,3
Tot_Number_Exception_C,10
Tot_Number_Exception_D,1
Tot_Number_Exception_E,1
;
run;

proc sgplot data=WORK.plot_graph;
   vbar Exception /response=tot_pcnt group=Exception  ;
   yaxis grid values=(0 to 12 by 2) display=(nolabel); 
   xaxis display=(nolabel) display=(noticks);
run;

thanks for your help

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Thanks for providing sample data, code and what you want!

 

For :

1. Add DATALABEL option to the VBAR statement

2. Change xaxis display option to NONE to suppress the XAXIS labels and tick marks. 

 

 

proc sgplot data=WORK.plot_graph;
   vbar Exception /response=tot_pcnt group=Exception datalabel ;
   yaxis grid values=(0 to 12 by 2) display=(nolabel); 
   xaxis display=none;
run;

@YNWA1 wrote:

Hi,

I can't really get the right options to display my desired graph using SGPLOT. 

Code producing the below.

 

1. I want the value to be displayed on top of each bar ( in red)

2. I want to hide the values along the xaxis (highlighted in yellow)

The legend needs to be displayed at the bottom

 

YNWA1_0-1630624958526.png

 

data plot_graph;
infile datalines dlm=",";
input Exception $22. tot_pcnt;
datalines;
Tot_Number_Exception_A,2
Tot_Number_Exception_B,3
Tot_Number_Exception_C,10
Tot_Number_Exception_D,1
Tot_Number_Exception_E,1
;
run;

proc sgplot data=WORK.plot_graph;
   vbar Exception /response=tot_pcnt group=Exception  ;
   yaxis grid values=(0 to 12 by 2) display=(nolabel); 
   xaxis display=(nolabel) display=(noticks);
run;

thanks for your help

 

 


 

 

 

 

View solution in original post

1 REPLY 1
Reeza
Super User

Thanks for providing sample data, code and what you want!

 

For :

1. Add DATALABEL option to the VBAR statement

2. Change xaxis display option to NONE to suppress the XAXIS labels and tick marks. 

 

 

proc sgplot data=WORK.plot_graph;
   vbar Exception /response=tot_pcnt group=Exception datalabel ;
   yaxis grid values=(0 to 12 by 2) display=(nolabel); 
   xaxis display=none;
run;

@YNWA1 wrote:

Hi,

I can't really get the right options to display my desired graph using SGPLOT. 

Code producing the below.

 

1. I want the value to be displayed on top of each bar ( in red)

2. I want to hide the values along the xaxis (highlighted in yellow)

The legend needs to be displayed at the bottom

 

YNWA1_0-1630624958526.png

 

data plot_graph;
infile datalines dlm=",";
input Exception $22. tot_pcnt;
datalines;
Tot_Number_Exception_A,2
Tot_Number_Exception_B,3
Tot_Number_Exception_C,10
Tot_Number_Exception_D,1
Tot_Number_Exception_E,1
;
run;

proc sgplot data=WORK.plot_graph;
   vbar Exception /response=tot_pcnt group=Exception  ;
   yaxis grid values=(0 to 12 by 2) display=(nolabel); 
   xaxis display=(nolabel) display=(noticks);
run;

thanks for your help

 

 


 

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 921 views
  • 2 likes
  • 2 in conversation