New Contributor
Posts: 3

# Monthly average returns

Hi to all,

I am new in SAS and I really would appreciate your help in how to continue with my data.

I have monthly average returns of an index for 20 years in two columns the one is the date column with the additional month and the other column is the return for the month.

So now my data is something like this:

date             return

1925/01        2,34

1925/02        3,76

1925/03        2,69

This keeps going until 12/1945. However I care about the average return of each month (January, February,..., December) for the whole period of the 20 years. So i want to transform my data in this form.

Month    Average Monthly return 1925-1945

Jan              2,98

Feb             3,67

March          3,29

Jun              2,43

Jul              .....

Aug            .....

Sept            .....

Οct            ......

Nov           .....

Dec           2,86

So i want know the average return individually for each for this period. I hope I am clear in what I am asking.

Posts: 3,167

## Re: Monthly average returns

Question: How is your date variable constructed? Is it a SAS date (numeric variable) or just a char as "1925/01"?

New Contributor
Posts: 3

## Re: Monthly average returns

Its numeric variable, (you are right, should specify that.)

 dates return 19260130 0.023174 19260227 -0.053510 19260331 -0.096824 19260430 0.032946 19260528 0.001035 19260630 0.050487 19260731 0.013076 19260831 0.031002 19260930 -0.006499 19261030 -0.034630
Posts: 3,167

## Re: Monthly average returns

This hopefully can get you started:

proc sql;

create table want as

select put(input(put(dates,8.),yymmdd8.),monname3.) as month, mean(return) as Average_1925_1945 from have

group by month

;quit;

Haikuo

PROC Star
Posts: 1,307

## Re: Monthly average returns

Another option:

PROC MEANS DATA=have MEAN;

VAR return;

CLASS date;

FORMAT date MONNAME9.;

RUN;

Tom

New Contributor
Posts: 3

## Re: Monthly average returns

Thank you both you have been really helpful, I managed to proceed!

Discussion stats
• 5 replies
• 703 views
• 6 likes
• 3 in conversation