I have a time series that I have run X11 on and have the resulting seasonal factors. I would like to create an average seaonal factor series for each seassonal factor. This means that each month will be the average of all other seasonal factors for that month.
For example, if the seasonal factors for January for a time series variable are:
Jan1999 5
Jan2000 10
Jan2001 15
Jan2002 20
Then the new average seasonal factor series will be the average of all January seasonal factors (5+10+15+20)/4=12.5. The same would be done for all 12 months. The output for this example would be
Jan1999 12.5
Jan2000 12.5
Jan2001 12.5
Jan2002 12.5
and so on. February would be the average of all other Februarys.
I tried proc means with class as my date, but this did not work.
Any ideas?
Do you want a data step?
Have 2 _temporary_ arrays, one(K) to hold the sum of VALs and another to hold the count of values added to each of 12 cells.
In the first pass of input data set, build the 2 arrays. In the second pass replace the values by the average computed using K[i] / C[i] where i = 1 to 12. If i-th cell is missing do not write out.
Try your means code with
Format <name of the data variable> monname3.;
You should get your cross year means and the date will look like Jan, Feb, Mar, ... , Dec.
You would have to do something else to merge back onto multiple records but you haven't shown quite enough information abou tyour data, variable names/types and such.
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.