BookmarkSubscribeRSS Feed
BCNAV
Quartz | Level 8

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?

2 REPLIES 2
KachiM
Rhodochrosite | Level 12

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.

 

 

ballardw
Super User

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.

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 Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 378 views
  • 0 likes
  • 3 in conversation