'Recode' functionality

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

liv27
Posts: 2
Joined: Wed Sep 24, 2014 8:25 am

'Recode' functionality

Postby liv27 » Wed Sep 24, 2014 8:36 am

Hello,

I was trying to get more information on how the 'recode' command works in EViews: logic behind; structure - is it similar to Excel's 'IF' function (condition, if true, if false); is a value of 1 = True and 0 = False; etc. Couldn't find any extended info in the EViews manuals.

Also, if you could tell me what the following code does would be greatly appreciated:
series ud = @recode(@isna(ud(-1)), ud_code = "Y", ud(-1)=1 or ud_code = "Y").

Thank you.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: 'Recode' functionality

Postby EViews Gareth » Wed Sep 24, 2014 8:51 am

Yep, works same was as IF in Excel.

Code: Select all

series ud = @recode(@isna(ud(-1)), ud_code = "Y", ud(-1)=1 or ud_code = "Y")
That's a bit of a crazy expression, but what it does is:

If the lagged value of UD is an NA, then set the values of UD equal to the expression UD_CODE="Y".
If the lagged value of UD is not an NA, then set the values of UD equal to the expression UD(-1)=1 or UD_CODE="Y".

The expression UD_CODE="Y" will return either a 1 or a 0 depending on whether the alpha series UD_CODE is equal to "Y" or not.

The expression UD(-1)=1 or UD_CODE="Y" will return either a 1 or a 0 depending jointly on whether the lagged value is equal to 1, or UD_CODE is equal to "Y".

So you'll end up with a series of 1s or 0s.

liv27
Posts: 2
Joined: Wed Sep 24, 2014 8:25 am

Re: 'Recode' functionality

Postby liv27 » Wed Sep 24, 2014 9:18 am

Thank you very much, Gareth! Just what I was looking for.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests