Calculating Mean of Seasonal Factors

Reply
Frequent Contributor
Posts: 79

Calculating Mean of Seasonal Factors

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?

Super Contributor
Posts: 311

Re: Calculating Mean of Seasonal Factors

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.

 

 

Super User
Posts: 12,148

Re: Calculating Mean of Seasonal Factors

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.

Ask a Question
Discussion stats
  • 2 replies
  • 84 views
  • 0 likes
  • 3 in conversation