Generate a series based on 3 conditions

For questions regarding programming in the EViews programming language.

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

Mai LÊ
Posts: 18
Joined: Mon May 06, 2019 7:09 am

Generate a series based on 3 conditions

Postby Mai LÊ » Sun Aug 14, 2022 7:06 am

Hi everyone,
I want to generate series w(t) with the following conditions:
w(t)=0 if a(t)<0
w(t)=a(t) if 0=<a(t)<=1
w(t)=1 if a(t)>1
Could anyone please help me on this command?
Normally with 2 conditions , I use @recode, but I don't know for 3 conditions.

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

Re: Generate a series based on 3 conditions

Postby startz » Sun Aug 14, 2022 10:14 am

Mai LÊ wrote:Hi everyone,
I want to generate series w(t) with the following conditions:
w(t)=0 if a(t)<0
w(t)=a(t) if 0=<a(t)<=1
w(t)=1 if a(t)>1
Could anyone please help me on this command?
Normally with 2 conditions , I use @recode, but I don't know for 3 conditions.

Code: Select all

wt = @recode(a<0,0,a)
wt = @recode(a>1,1,wt)

Mai LÊ
Posts: 18
Joined: Mon May 06, 2019 7:09 am

Re: Generate a series based on 3 conditions

Postby Mai LÊ » Tue Aug 16, 2022 5:55 am

Thanks so much!

EViews Glenn
EViews Developer
Posts: 2671
Joined: Wed Oct 15, 2008 9:17 am

Re: Generate a series based on 3 conditions

Postby EViews Glenn » Wed Aug 17, 2022 12:11 pm

Note that In this specific case, the @bounds function will do both parts of the bounded assignment:

Code: Select all

series w = @bounds(a, 0, 1)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 21 guests