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
I think I got it.. using:
avg=Mean(of x y z);
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)
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.