Hello,
I have 90 lines of data. I want to calculate the mean and some other metrics for the first 35 years of data, then for years 2-36, then 3-37, etc and then view all of these mean series. How do I do this? Thanks very much for your help.
Can you show us your data?
One method is using a multilabel format
Example:
proc format;
value yearf (multilabel)
1-35='1-35'
2-36='2-36'
3-37='3-37'
/* I'm lazy, you type the rest */
;
run;
proc summary data=have nway;
class year_since_start/mlf format=yearf.;
var some_other_variables;
output out=_stats_ mean= std= min= max=/autoname;
run;
Another method, if you have SAS/ETS and PROC EXPAND, is to calculate moving averages of length 35 based upon your year variable. Probably less typing.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.