BookmarkSubscribeRSS Feed
GemmaR
SAS Employee
Hi All,

I've been asked to generate a bar chart that shows the frequency of an event occurring by week (used number of observations as freq). Now that's the ok part (I think)- done a bar chat and formatted the date so it's a week format.

But now what they want is an monthly average of the frequency plotted as a line with the midpoints being the line joining the second and the third week.

Does this make sense at all? I have a feeling the lovely annotate is on the cards!
:-)


Any help would be greatly received!
Many Thanks
Gemma
8 REPLIES 8
mfisher
Fluorite | Level 6
Sounds like you need a bar chart on the first Y axis and a line plot of the mean on the second Y axis, centered on the 15th of the month.

Here's an example of a bar-line chart, using sgplot:

http://support.sas.com/documentation/cdl/en/grstatproc/62603/HTML/default/viewer.htm#a003199396.htm
GemmaR
SAS Employee
Hi Mfisher,

Thank you so much for your reply, that's exactly what I need.

Unfortunately I am still on SAS 9.1 Service Pack 4 with no view to upgrade in the near future.

Any other thoughts? Many thanks again.
GraphGuy
Meteorite | Level 14
If you had v9.2, you could also use "proc gbarline".

But since you're stuck with an older version of SAS, you might have to use a "proc gchart" bar chart, and annotate the line. Here's an example:

http://robslink.com/SAS/democd31/shoebar.htm
GemmaR
SAS Employee
Thanks Robert.

I thought I was going to have to use the annotate line, haven't done that in a while. I'm sure it's just like riding a bike huh?!?!

Many thanks for you help!
GraphGuy
Meteorite | Level 14
Yep - annotate is like riding a bike ... don't get your pants-leg caught in the chain! 😉
GemmaR
SAS Employee
Ha ha! Yeah, definately not one for the floaty summer skirt!

I'm sure I will be bugging you some more before this has finished!

bring on 9.2!
GraphGuy
Meteorite | Level 14
Oh - and I guess it would help if I'd post the code, and not just the output 😉

http://robslink.com/SAS/democd31/shoebar_info.htm
GemmaR
SAS Employee
Don't worry, I've used your great site before so I managed to find it using your lovely filing system.
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
  • 8 replies
  • 2855 views
  • 0 likes
  • 3 in conversation