how should i write codes about this? Thank you!

For questions regarding programming in the EViews programming language.

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

cystleren
Posts: 6
Joined: Wed Oct 29, 2008 10:53 am

how should i write codes about this? Thank you!

Postby cystleren » Wed Oct 29, 2008 11:22 am

I have a series called A (a1, a2, a3). What i want to do is if (a1,a2,a3) >65 then a new series B = (a1-65,a2-65,a3-65) generated; if not then the observation which below 65 returns 0. For example, A = (98,68,63) then B = (98-65,68-65,0)=(33,3,0). My code is like
if A > 65 then genr B = A-65 else genr B =0 endif
The problem is that the series B is always generated as all 0. Could you please suggest me how should I change this code? Thank you!!!

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: how should i write codes about this? Thank you!

Postby startz » Wed Oct 29, 2008 11:31 am

I have a series called A (a1, a2, a3). What i want to do is if (a1,a2,a3) >65 then a new series B = (a1-65,a2-65,a3-65) generated; if not then the observation which below 65 returns 0. For example, A = (98,68,63) then B = (98-65,68-65,0)=(33,3,0). My code is like
if A > 65 then genr B = A-65 else genr B =0 endif
The problem is that the series B is always generated as all 0. Could you please suggest me how should I change this code? Thank you!!!
You want the @recode function

Code: Select all

series b = @recode(a>65,a-65,0)
Alternatively,

Code: Select all

series b = (a>65)*(a-65) + (a<=65)*0

cystleren
Posts: 6
Joined: Wed Oct 29, 2008 10:53 am

Re: how should i write codes about this? Thank you!

Postby cystleren » Wed Oct 29, 2008 11:59 am

It works very well! Thanks a lot!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests