BookmarkSubscribeRSS Feed
VD
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.
Vikas
3 REPLIES 3
GraphGuy
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;
datalines;
1 2 .20
2 5 .50
3 3 .30
;
run;

symbol1 value=none interpol=none;
proc gbarline data=foo;
bar barnum / type=sum sumvar=value;
plot / sumvar=pct;
run;
VD
Calcite | Level 5 VD
Calcite | Level 5
Robert, this is very helpful. Thanks for both the answers. Vikas.
GraphGuy
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;
run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 952 views
  • 0 likes
  • 2 in conversation