## Showing average on a histogram

Regular Contributor
Posts: 218

# Showing average on a histogram

Hi All,

Following code gives me histogram showing total count in Y axis. Can someone tell me how do I get average instead of total count? Thanks.

proc sgplot data=have;

vbar Start_Date / stat=freq

groupdisplay=cluster group=event;

keylegend / location=inside position=topright;

where event in ('volley ball','soccer') and Start_date between "01Mar2014"d and "30Apr2014"d;

format Start_Date weekdate10.;

run;

Super User
Posts: 19,770

## Re: Showing average on a histogram

A histogram by definition shows frequency.

Change the STAT= in the VBAR statement - to MEAN instead of FREQ to plot a bar chart with the mean value instead of counts.

Regular Contributor
Posts: 218

## Re: Showing average on a histogram

Hi Reeza,

Changed that to mean, still not working. can you please tell why.

proc sgplot data=have;

vbar Start_Date / stat=mean

groupdisplay=cluster group=event;

keylegend / location=inside position=topright;

where event in ('volley ball','soccer') and Start_date between "01Mar2014"d and "30Apr2014"d;

format Start_Date weekdate10.;

run;

Super User
Posts: 19,770

## Re: Showing average on a histogram

Can you post some sample data and explain what 'still not working' means?

Regular Contributor
Posts: 218

## Re: Showing average on a histogram

Hi Reeza,

I have Feb and Mar data of both 2014 and 2015.

Thanks,

 Date Outcome 01-Mar-2014 Loss 27-Feb-2015 Profit 27-Feb-2014 Loss 24-Feb-2014 Profit 01-Mar-2015 Loss 26-Feb-2015 Loss 01-Mar-2015 Loss 01-Mar-2015 Loss 01-Mar-2015 Loss 01-Mar-2015 Profit 01-Mar-2014 Profit 01-Mar-2014 Profit 01-Mar-2014 Profit 25-Feb-2014 Profit
Super User
Posts: 19,770

## Re: Showing average on a histogram

What are the numbers you're trying to take the average of?

Regular Contributor
Posts: 218

## Re: Showing average on a histogram

HI Reeza,

I created a frequency table from the above table call Table_freq. It has the no of outcome (both loss and profit in one column though) on each date. I tried to run that report from that table with the following code.

proc sgplot data=Apple.Table_freq;

vbar Date / stat=freq

groupdisplay=cluster group=Outcome;

keylegend / location=inside position=topright;

format Start_Date weekdate10.;

run;

Discussion stats
• 6 replies
• 370 views
• 0 likes
• 2 in conversation