BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a chart variable and a group variable,i need to create Horizontal bar charts out of those.

My data looks like these

Grp C_Var G_FREQ C_var_pct
1 X 1000 50%
1 Y 1000 60%
1 Z 1000 70%
2 X 2000 40%
2 Y 2000 60%

Grp is the Group Variable and C_Var is the Chart Variable

The Length of the bars should reflect the C_var_pct and value of variables G_FREQ and C_var_pct should be present in the outputs.

Can you guys help me out on this.

Message was edited by: RKarthik Message was edited by: RKarthik
2 REPLIES 2
GraphGuy
Meteorite | Level 14
There are basically 2 ways to plot this data that come to mind - I'm sure
exactly which way you're wanting, so I included both...


data foo;
input Grp C_Var $ G_FREQ C_var_pct;
datalines;
1 X 1000 .50
1 Y 1000 .60
1 Z 1000 .70
2 X 2000 .40
2 Y 2000 .60
;
run;

proc gchart data=foo;
hbar grp / discrete type=sum sumvar=c_var_pct subgroup=c_var nostats;
run;

proc gchart data=foo;
hbar c_var / type=sum sumvar=c_var_pct group=grp patternid=midpoint nostats;
run;
deleted_user
Not applicable
Thanks Robert!

I think my question was not clear, anyways I solved my problem using weighted statistics option in proc gchart

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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