Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Showing average on a histogram

Reply
Regular Contributor
Posts: 215

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: 17,837

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: 215

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: 17,837

Re: Showing average on a histogram

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

Regular Contributor
Posts: 215

Re: Showing average on a histogram

Hi Reeza,

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

Thanks,

DateOutcome
01-Mar-2014Loss
27-Feb-2015Profit
27-Feb-2014Loss
24-Feb-2014Profit
01-Mar-2015Loss
26-Feb-2015Loss
01-Mar-2015Loss
01-Mar-2015Loss
01-Mar-2015Loss
01-Mar-2015Profit
01-Mar-2014Profit
01-Mar-2014Profit
01-Mar-2014Profit
25-Feb-2014Profit
Super User
Posts: 17,837

Re: Showing average on a histogram

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

Regular Contributor
Posts: 215

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.

Thanks for your help.

proc sgplot data=Apple.Table_freq;

vbar Date / stat=freq

  groupdisplay=cluster group=Outcome;

  keylegend / location=inside position=topright;

  format Start_Date weekdate10.;

run;

Ask a Question
Discussion stats
  • 6 replies
  • 358 views
  • 0 likes
  • 2 in conversation