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

 

 


 

 

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 470 views
  • 2 likes
  • 2 in conversation