Page 1 of 1

search x and replace with Y IF (eviews 7)

Posted: Thu Apr 29, 2010 1:35 pm
by mark
Hi
I have a series with 65,000 observations where the value varies from 1 to 12
I need to find values 1 to 3, 4 though 6, 7 through 9 and 10 through 12 then generate a new series containing values of 1, 2, 3, or 4 in the approrpiate cells
I've been attempting this with the following code to no avail
Any suggestions would be appreciated


program mytest
workfile test u 1 65535
fetch allbids09:: openingdate
' transforming date string to common units
series test=@datepart(openingdate, "mm")
series test2=@datepart(openingdate, "yy")
if test >=1 and test <=3 then
series qrtr =1
if test >3 and test <=6 then
series qrtr2=2
if test>6 and test <=9 then
series qrtr3=3
'if test>9 and test <=12 then
series qrtr4=4
endif
endif
endif
endif

Re: search x and replace with Y IF (eviews 7)

Posted: Thu Apr 29, 2010 1:43 pm
by EViews Gareth
You can't use IF statements on series.

Either assign a binary test to the series directly (with no if):

Code: Select all

series qrt1 = test>1 and test<=3
or use the @recode function

Code: Select all

series qrt1 = @recode(test>1 and test<=3, 1, 0)
or use the smpl statement:

Code: Select all

smpl if test>1 and test<=3 series qrt1 = 1 smpl @all
Of course, looking through your earlier code, it might be simpler to just do:

Code: Select all

series qrt1 = @datepart(openingdate, "q") = 1

Re: search x and replace with Y IF (eviews 7)

Posted: Thu Apr 29, 2010 2:03 pm
by mark
thanks - would have taken me a week
have 2 beers on me