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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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