BookmarkSubscribeRSS Feed
mlogan
Lapis Lazuli | Level 10

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;

6 REPLIES 6
Reeza
Super User

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.

mlogan
Lapis Lazuli | Level 10

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;

Reeza
Super User

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

mlogan
Lapis Lazuli | Level 10

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
Reeza
Super User

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

mlogan
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

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