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

I plotted a horizontal Barchart using sgplot. All works fine, the only problem I have, is that  I wish to rotate the whole graph so that the 

yaxis which is now on the left hand side, is turned to the right hand side. Also is there anyway to get rid of the vertical line on the yaxis? can anyone help?

export.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Use Y2AXIS as suggested by RW9 (see bold options in code below).  Also, you can remove the baseline by setting BASELINEATTRS=(thickness=0) on the HBAR.  I would put the grid on the xaxis.

 

proc sgplot data=sg.test2 noborder nowall; 
hbar types / response=total barwidth=0.5 y2axis missing datalabel fillattrs=(color=gray)
     baselineattrs=(thickness=0);
y2axis display=(nolabel noline noticks) discreteorder=data; 
xaxis display=(nolabel noline novalues noticks) max=3000 reverse grid;
run;

 

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You can set the display on yaxis to none:

http://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n0n6uml63c6h8dn16phbd1arm9g9.htm&docs...

See display.

 

Then you can setup the y2axis as you want to display it:

http://support.sas.com/documentation/cdl/en/grstatproc/65235/HTML/default/viewer.htm#n04drrb1aehuqzn...

 

You will find this blog helpful as it has thousands of examples of all types of graphs:

http://blogs.sas.com/content/graphicallyspeaking/

Jay54
Meteorite | Level 14

And, if you also want the bars to go from right to left, then you can use the REVERSE option on the XAXIS.

Anita_n
Pyrite | Level 9

Thanks for your quick responses. I tried both methods but haven't still got it working. when I use reverse on the xaxis I get something like this:  dok1.jpg

 How do I get the labels on the left handside? Also I wish to get rid of the line holding the bars. Is there any way to do that?

 

Anita_n
Pyrite | Level 9

let me just post the sas code here incase someone can help. I will be very gratefull for any help. Thanks

proc sgplot data=sg.test2 noborder nowall;
yaxis grid type=discrete discreteorder=data; 
hbar types /response=total barwidth=0.5 missing datalabel fillattrs=(color=gray);
yaxis display=(nolabel noline noticks); 
xaxis display=(nolabel noline novalues noticks) max=3000 reverse;
run;

and here is the input data

Jay54
Meteorite | Level 14

Use Y2AXIS as suggested by RW9 (see bold options in code below).  Also, you can remove the baseline by setting BASELINEATTRS=(thickness=0) on the HBAR.  I would put the grid on the xaxis.

 

proc sgplot data=sg.test2 noborder nowall; 
hbar types / response=total barwidth=0.5 y2axis missing datalabel fillattrs=(color=gray)
     baselineattrs=(thickness=0);
y2axis display=(nolabel noline noticks) discreteorder=data; 
xaxis display=(nolabel noline novalues noticks) max=3000 reverse grid;
run;

 

Anita_n
Pyrite | Level 9

Okay, thanks a lot Sanjay, I will try that and let you know if it worked. my regards

Anita_n
Pyrite | Level 9
Thankyou very much Sanjay. It worked very fine. I have also in included the grid on the xaxis.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 7 replies
  • 4503 views
  • 3 likes
  • 3 in conversation