Data visualization with SAS programming

Average of a frequency?!

Reply
SAS Employee
Posts: 190

Average of a frequency?!

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
Contributor
Posts: 58

Re: Average of a frequency?!

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
SAS Employee
Posts: 190

Re: Average of a frequency?!

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.
SAS Employee
Posts: 980

Re: Average of a frequency?!

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
SAS Employee
Posts: 190

Re: Average of a frequency?!

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!
SAS Employee
Posts: 980

Re: Average of a frequency?!

Yep - annotate is like riding a bike ... don't get your pants-leg caught in the chain! ;-)
SAS Employee
Posts: 190

Re: Average of a frequency?!

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!
SAS Employee
Posts: 980

Re: Average of a frequency?!

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
SAS Employee
Posts: 190

Re: Average of a frequency?!

Don't worry, I've used your great site before so I managed to find it using your lovely filing system.
Ask a Question
Discussion stats
  • 8 replies
  • 232 views
  • 0 likes
  • 3 in conversation