Creating a new yearly series

For questions and discussion related to reading in and working with data.
msrahman
Posts: 53
Joined: Wed Oct 31, 2012 2:32 pm

Creating a new yearly series

Unread post by msrahman »

Hello,

I have daily interest rate data for 35 years. I want to create a new series that simply takes numbers from 1 to 35 corresponding to the years in the original series. I can use "set year = %year(t)", but that gives me the original years such as1973,1974 etc. I want to replace the years with numbers 1, 2,.....

Any help would be appreciated.

Sajjadur.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Creating a new yearly series

Unread post by TomDoan »

In the specific case,

set year = %year(t)-1972

If you want to be more flexible:

set year = %year(t)-%year(1)+1

which will base the year number off the initial year (%year(1))
msrahman
Posts: 53
Joined: Wed Oct 31, 2012 2:32 pm

Re: Creating a new yearly series

Unread post by msrahman »

Thanks for your help.

Sajjadur
msrahman
Posts: 53
Joined: Wed Oct 31, 2012 2:32 pm

Re: Creating a new yearly series

Unread post by msrahman »

Hello, Just a quick follow up regarding my earlier inquiry.

When I use
set year = %year(t)-%year(1)+1

I find a number of missing data points indicated as NA. How to avoid those missing data points?
I have attached the file here.
Thanks.

Sincerely,
Sajjadur.
Attachments
Oil_price.xls
(712 KiB) Downloaded 761 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Creating a new yearly series

Unread post by TomDoan »

You have daily data with gaps for holidays. If you read that as dated daily data, it will insert NA's to make the data a regular five-day-a-week series. See Section 2.6 in the Introduction for ways to handle this. Probably the simplest thing in your case is to add the YEAR variable to the original data set (which uses an Excel expression almost identical to the SET instruction) and read the data set as undated.
Post Reply