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-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1493 views
  • 0 likes
  • 2 in conversation