BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

Hi,  Is there a way SAS allows to do a mean across varaibles (and use a BY statement).

Here's what I mean:

HAVE:

Prod   Price1  Price2  Price3  Price4

A          2          4          7         6
B          3          .           5        3

C          .          5          .         .

D          .           .           .         .

WANT:   If I want the MEAN of the last 3 Prices & last 4 Prices

Prod   Month3_Prices         Month4_Prices

A                5.6                            4.7
B                 4                              3.6

C                 5                                5

D                 .                                .      

I tried different variations of Proc MEAN, couldn't get it, but I'm sure there is a simple way.

Thanks

3 REPLIES 3
podarum
Quartz | Level 8

I think I got it.. using:

avg=Mean(of x y z);

Reeza
Super User

Yes, except you can do mean(of price1--price3)  and mean (of price1--price4) as well as mean(price1, price2, price3)  and mean(price1, price2, price3, price4)

Astounding
PROC Star

Well, it may not be everyone's idea of fun, but here's a program you can play around with ... "just for fun".

data _null_;

p1=1;

p3=3;

p2=4;

of=20;

m1 = mean(of p1--p3);

m2 = mean(of p1-p3);

m3 = mean(of p1 p2 p3);

m4 = mean(of p1,p2,p3);

m5 = mean(of,p1,p2,p3);

put m1= m2= m3= m4= m5=;

run;

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 18554 views
  • 0 likes
  • 3 in conversation