Dropping created variables from the "current dataset"

For questions and discussion related to reading in and working with data.
SRedford
Posts: 4
Joined: Mon Jul 07, 2014 4:48 am

Dropping created variables from the "current dataset"

Unread post by SRedford »

Hi,

So possibly another strange/terribly ignorant question, but is there a way to drop variables from a set of created data? The code I am using is below.

In short, I have read 14 variables from an excel file into RATS and then created a whole bunch of other variables, most of which I have done so by using loops. There are a few that I do not want to keep, and I tried the DELETE command, but this did not work. I realise this is because it works on saved data files only and my created data is effectively in a "RAM" version of the dataset. Is there a solution that I have missed?

Many thanks.

Regards
Siobhan Redford

Code: Select all

OPEN DATA "C:\Users\p174343\PhD\Yield curve\CFS\Monthlydata.xlsx"
CALENDAR(m) 1986:01:31
DATA(FORMAT=XLSX,ORG=COLUMNS) 1986:01:31 2014:06:30 TB3 JAYC1 JAYC2 JAYC3 JAYC4 JAYC5 JAYC6 JAYC7 $
JAYC8 JAYC9 JAYC10 JAYC15 JAYC20 JAYC25

dofor i = TB3 to JAYC25
set %s("D3"+%l(i)) = (i{3})-(i{0})
end dofor i

dofor i = JAYC1 to JAYC25
set %s("D12"+%l(i)) = (i{12})-(i{0})
end dofor i

dofor i = JAYC4 to JAYC20
set %s("D24"+%l(i)) = (i{24})-(i{0})
end dofor i

dofor i = JAYC10 to JAYC25
set %s("D60"+%l(i)) = (i{60})-(i{0})
end dofor i

dofor i = JAYC1 to JAYC25
set %s("S3"+%l(i)) = (i{0})-(TB3{0})
end dofor i

dofor i = JAYC2 to JAYC25
set %s("S12"+%l(i)) = (i{0})-(JAYC1{0})
end dofor i

dofor i = JAYC4 to JAYC20
set %s("S24"+%l(i)) = (i{0})-(JAYC2{0})
end dofor i

delete D24JAYC5 S24JAYC5 D24JAYC7 S24JAYC7 D24JAYC9 S24JAYC9 D24JAYC15 S24JAYC15

dofor i = JAYC10 to JAYC25
set %s("S60"+%l(i)) = (i{0})-(JAYC5{0})
end dofor i
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dropping created variables from the "current dataset"

Unread post by TomDoan »

Can't you just ignore them? That's not a data set that's going to produce any memory shortages.
SRedford
Posts: 4
Joined: Mon Jul 07, 2014 4:48 am

Re: Dropping created variables from the "current dataset"

Unread post by SRedford »

I could, but it would create an additional problem in which I then have to scale the variables using a particular formula, which I haven't managed to figure out how to code, especially since the end variables are not consecutive and then use those for the regressions. By not having the variables I want to drop, I can then run the regressions I will be running using these created variables using a loop as everything is then in order.

This is the set of variables I create next :

Code: Select all

set AS3JAYC1 = S3JAYC1/3
set AS3JAYC2 = S3JAYC2/7
set AS3JAYC3 = S3JAYC3/11
set AS3JAYC4 = S3JAYC4/15
set AS3JAYC5 = S3JAYC5/19
set AS3JAYC6 = S3JAYC6/23
set AS3JAYC7 = S3JAYC7/27
set AS3JAYC8 = S3JAYC8/31
set AS3JAYC9 = S3JAYC9/35
set AS3JAYC10 = S3JAYC10/39
set AS3JAYC15 = S3JAYC15/59
set AS3JAYC20 = S3JAYC20/79
set AS3JAYC25 = S3JAYC25/99
set AS12JAYC2 = S12JAYC2
set AS12JAYC3 = S12JAYC3/2
set AS12JAYC4 = S12JAYC4/3
set AS12JAYC5 = S12JAYC5/4
set AS12JAYC6 = S12JAYC6/5
set AS12JAYC7 = S12JAYC7/6
set AS12JAYC8 = S12JAYC8/7
set AS12JAYC9 = S12JAYC9/8
set AS12JAYC10 = S12JAYC10/9
set AS12JAYC15 = S12JAYC15/14
set AS12JAYC20 = S12JAYC20/19
set AS12JAYC25 = S12JAYC25/24
set AS24JAYC4 = S24JAYC4
set AS24JAYC6 = S24JAYC6/2
set AS24JAYC8 = S24JAYC8/3
set AS24JAYC10 = S24JAYC10/4
set AS24JAYC20 = S24JAYC20/9
set AS60JAYC10 = S60JAYC10
set AS60JAYC15 = S60JAYC15/2
set AS60JAYC20 = S60JAYC20/3
set AS60JAYC25 = S60JAYC25/4

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

Re: Dropping created variables from the "current dataset"

Unread post by TomDoan »

Sorry. I'm trying to figure out the pattern for those, but I'm not sure I see it. What are the conventions in the names?
SRedford
Posts: 4
Joined: Mon Jul 07, 2014 4:48 am

Re: Dropping created variables from the "current dataset"

Unread post by SRedford »

They are yields on zero coupon bonds of maturity 1, 2, 3 years etc as indicated by the numbers at the end of the name. I am adjusting spreads similar to Campbell and Shiller 1991 (Yield spreads and interest movements: a bird's eye view, Review of Economic Studies, v 58, p 495 - 514). Basically they are being divided by (1/time to maturity - 1), in months, it would be easier to write a loop if I didn't skip years from 10 to 25. Also, the requirement is that the maturity of the short yield is divides exactly into the long yield. Which is why I would like to drop the non-integer yields. Does this make some sense?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dropping created variables from the "current dataset"

Unread post by TomDoan »

Code: Select all

set AS3JAYC1 = S3JAYC1/3
set AS3JAYC2 = S3JAYC2/7
set AS3JAYC3 = S3JAYC3/11
set AS3JAYC4 = S3JAYC4/15
set AS3JAYC5 = S3JAYC5/19
set AS3JAYC6 = S3JAYC6/23
set AS3JAYC7 = S3JAYC7/27
set AS3JAYC8 = S3JAYC8/31
set AS3JAYC9 = S3JAYC9/35
set AS3JAYC10 = S3JAYC10/39
set AS3JAYC15 = S3JAYC15/59
set AS3JAYC20 = S3JAYC20/79
set AS3JAYC25 = S3JAYC25/99
can be handled with a DOFOR loop across the term:

dofor term = 1 to 10 15 20 25
set %s("AS3JAYC"+term) = %s("S3JAYC"+term)/(4*term-1)
end dofor term

It looks like something similar with work with the others.
Post Reply