BookmarkSubscribeRSS Feed
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Hello all;
The first question is,
how do I create a vertical bar graph that consists of multiple groups (RN, MD, RT,etc), ordered by month that the different groups don't end up stacked, but rather next to each other as I get when I perform such code:


proc sgplot data=AGGREGATEG;
vbar fx/ response=compliance group=type;
run;

The goal is that the compliance is the Y axis, the months are the X axis with the groups in 4 different vertical bars.

Some observations below:
Thanks

Lawrence


Obs fx COMPLIANCE DENOMS NUMY TYPE

1 JUL10 0.81250 32 26 RN
2 AUG10 0.91525 59 54 RN
3 SEP10 0.58209 134 78 RN
4 OCT10 0.43750 80 35 RN
5 JUL10 0.60000 5 3 MD
6 AUG10 0.40000 10 4 MD
7 SEP10 0.42373 59 25 MD
8 OCT10 0.30667 75 23 MD
9 JUL10 0.00000 2 0 RT
10 AUG10 0.66667 3 2 RT
11 SEP10 1.00000 2 2 RT
12 OCT10 0.66667 3 2 RT
13 JUL10 0.81250 16 13 OT
14 AUG10 0.85000 20 17 OT
15 SEP10 0.23913 46 11 OT
16 OCT10 0.48485 33 16 OT
7 REPLIES 7
GraphGuy
Meteorite | Level 14
Sounds like you want a "grouped bar chart" ... I would recommend using good-old "proc gchart" - perhaps something like the following:

data mydata;
length type $2.;
format fx monyy7.;
format compliance percent7.0;
input fx date7. compliance denoms numy type;
datalines;
15JUL10 0.81250 32 26 RN
15AUG10 0.91525 59 54 RN
15SEP10 0.58209 134 78 RN
15OCT10 0.43750 80 35 RN
15JUL10 0.60000 5 3 MD
15AUG10 0.40000 10 4 MD
15SEP10 0.42373 59 25 MD
15OCT10 0.30667 75 23 MD
15JUL10 0.00000 2 0 RT
15AUG10 0.66667 3 2 RT
15SEP10 1.00000 2 2 RT
15OCT10 0.66667 3 2 RT
15JUL10 0.81250 16 13 OT
15AUG10 0.85000 20 17 OT
15SEP10 0.23913 46 11 OT
15OCT10 0.48485 33 16 OT
;
run;

axis1 label=('Compliance') order=(0 to 1 by .2) minor=none offset=(0,0);
axis2 label=none offset=(3,3);
axis3 label=none;

proc gchart data=mydata;
vbar type / discrete type=sum sumvar=compliance
group=fx raxis=axis1 maxis=axis2 gaxis=axis3;
run;
DanH_sas
SAS Super FREQ
Here are a few variations you can use using SGPANEL:

[pre]
proc sgpanel data=AGGREGATEG;
panelby type / onepanel noborder layout=columnlattice;
vbar fx/ response=compliance;
run;
[/pre]

[pre]
proc sgpanel data=AGGREGATEG;
panelby type / onepanel noborder layout=rowlattice;
hbar fx/ response=compliance;
run;
[/pre]

[pre]
proc sgpanel data=AGGREGATEG;
panelby type; /* optionally add ROWS, COLUMNS, or ONEPANEL */
vbar fx/ response=compliance;
run;
[/pre]

For the first two, you can also move the header down and use a legend:

[pre]
proc sgpanel data=AGGREGATEG;
panelby type / onepanel noborder layout=columnlattice colheaderpos=bottom;
vbar fx/ response=compliance group=type;
run;
[/pre]

[pre]
proc sgpanel data=AGGREGATEG;
panelby type / onepanel noborder layout=rowlattice rowheaderpos=left;
hbar fx/ response=compliance group=type;
run;
[/pre]

Let me know if this is what you're after.

Thanks!
Dan
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Dan & Robert;
Thank you both for your suggestions. It gets me going but I am going to have to do a lot of manipulations...

But Robert, or Dan

so I am going to have an compliance overall rate at some juncture as a vline with the datalabels in big fat yellow bubbles connected by a line. I'd rather concatenate the overall rate with the month but mgmt will not go along with that idea.

I am just attempting to free up the other analyst, as the data above represents only 1 of 40 units that have to be graphed in Excel manually.

Thanks

Lawrence
GraphGuy
Meteorite | Level 14
You can do that in 'gchart' using annotate.

The yellow bubble can be done with function='pie' and the text can be done with function='label'.
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Thanks Robert!
Jay54
Meteorite | Level 14
Can you attach an image to indicate what you want?
_LB
Fluorite | Level 6 _LB
Fluorite | Level 6
Sanjay;
I wish I could do that, but this forum does not allow for that..

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 7 replies
  • 2089 views
  • 1 like
  • 4 in conversation