BookmarkSubscribeRSS Feed
Calcite | Level 5 VD
Calcite | Level 5
I'm facing two issues in plotting histograms in gchart, if anyone could advise please?

1) How to display y-axis on both the sides of the graph, one side displaying frequencies and the other side displaying percentages?

2)On the x-axis, how to label the bars only after (say) 5 points and yet display all the bars? For instance, how to have a bar for each point from 0 to 80 (0,1,2..80) and display the labels for bars only at (0, 5, 10...80)?

I tried in proc univariate as well but couldn't work it out. Thanks.
Meteorite | Level 14
The easiest way to get an axis on the left & right side of a bar chart is using "proc gbarline". If your version of SAS is not new enough to have gbarline, then you could use "proc gchart" and then annotate the tickmarks & values along the right-side of the graph (a little tricky, but do-able).

Here's some basic gbarline code, to get you started:

data foo;
input barnum value pct;
format pct percent5.0;
1 2 .20
2 5 .50
3 3 .30

symbol1 value=none interpol=none;
proc gbarline data=foo;
bar barnum / type=sum sumvar=value;
plot / sumvar=pct;
Calcite | Level 5 VD
Calcite | Level 5
Robert, this is very helpful. Thanks for both the answers. Vikas.
Meteorite | Level 14
Per your 2nd question - you can use an axis statement with "proc gchart", and it will let you specify custom text (including a blank value) for each tickmark value of the axis, referring to them by number ( t=1 is the first bar midpoint value, t=2 is the second, and so on).

Here is some sample code, that shows how to blank out the first 5 values:

axis1 value=(t=1 '' t=2 '' t=3 '' t=4 '' t=5 '');

proc gchart data=sashelp.class;
hbar name / type=sum sumvar=height maxis=axis1;



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2 in conversation