Page 1 of 1

Generate a series based on 3 conditions

Posted: Sun Aug 14, 2022 7:06 am
by Mai LÊ
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.

Re: Generate a series based on 3 conditions

Posted: Sun Aug 14, 2022 10:14 am
by startz
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)

Re: Generate a series based on 3 conditions

Posted: Tue Aug 16, 2022 5:55 am
by Mai LÊ
Thanks so much!

Re: Generate a series based on 3 conditions

Posted: Wed Aug 17, 2022 12:11 pm
by EViews Glenn
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)