Creating indices

For questions and discussion related to reading in and working with data.

Creating indices

Postby terrya » Wed Oct 13, 2010 4:27 pm

How can one create indices of the type Ind = 100*y(t)/y(t=n), where n is the particular observation on which the index is based?
terrya
 
Posts: 37
Joined: Mon Aug 24, 2009 6:05 pm

Re: Creating indices

Postby terrya » Wed Oct 13, 2010 5:48 pm

I should have said that I was looking for something cleverer than just using the actual value, something like the @elem instruction in EViews
terrya
 
Posts: 37
Joined: Mon Aug 24, 2009 6:05 pm

Re: Creating indices

Postby TomDoan » Thu Oct 14, 2010 9:40 am

set Ind = 100*y(t)/y(n)

or

set IND = 100*y/y(n)

RATS uses series{l} for lags and leads, and series(n) for references to specific entries.
TomDoan
 
Posts: 3701
Joined: Wed Nov 01, 2006 5:36 pm

Re: Creating indices

Postby marcushemma » Fri Jun 03, 2011 12:18 pm

How would that look if you want to create indices, with reference to a specific entry, e.g. 2000:1, for a number of series?
I tried a number of variations based on a do loop with the series as i = 1,n but that didn't work.

Any suggestions?
marcushemma
 
Posts: 4
Joined: Sat Jun 12, 2010 3:12 am

Re: Creating indices

Postby TomDoan » Sat Jun 04, 2011 6:49 pm

marcushemma wrote:How would that look if you want to create indices, with reference to a specific entry, e.g. 2000:1, for a number of series?
I tried a number of variations based on a do loop with the series as i = 1,n but that didn't work.

Any suggestions?


Something like:

Code: Select all
dofor i = dpfood dpvice dpdura
   set(scratch) i = i{0}/([series] i)(1950:1)
end do i


You need to "cast" the index to a series in order to do the reference to a specific entry.
TomDoan
 
Posts: 3701
Joined: Wed Nov 01, 2006 5:36 pm

Re: Creating indices

Postby marcushemma » Wed Jun 08, 2011 4:02 am

It works fine until the date for the base of the index but not afterwards. Here's an example that uses some data from the Enders' files.

Code: Select all
cal 1959 1 4
all 2001:1
OPEN DATA "\Enders\Money_dem.xls"
DATA(FORMAT=XLS,ORG=COLUMNS) 1959:01 2001:01 DATE GDP RGDP M2 M3 TB3mo TB1yr
open data a:\money_dem.xls
data(org=obs,format=xls)

dofor i = gdp rgdp m2 m3
    set i =  i{0}/([series] i)(1960:1)
end do i
GRAPH(STYLE=LINE,KEY=BELOW) 4
# GDP
# RGDP
# M2
# m3

pri / gdp rgdp m2 m3
marcushemma
 
Posts: 4
Joined: Sat Jun 12, 2010 3:12 am

Re: Creating indices

Postby TomDoan » Wed Jun 08, 2011 7:57 am

Sorry about that. If you overwrite the series, you need a SCRATCH option on the SET instruction. I've corrected the code in the previous post.
TomDoan
 
Posts: 3701
Joined: Wed Nov 01, 2006 5:36 pm


Return to Data: Reading, Writing, Transforming

Who is online

Users browsing this forum: No registered users and 1 guest

cron