Page 1 of 1

How to run the program for Sampled year only and get result

Posted: Wed Jan 17, 2018 2:13 am
by nidhijain
I am an EViews10 user.
I have a series from 1990 to 2050, which has mix set of values, 0, positive and negative.(attached work file). I want to check the values inside series for each year from 2022 to 2050 separately and publish result as passed if value is positive and failed if negative.

I have tried using both these methods, but no luck. Every time, this code runs, even after taking sample, the condition run for entire series from 1990 to 2050 and not for one single year, and publish result as "passed" even for negative value years.

Please help how to run the program only for the sampled year and get the desired result.

Method 1:

logmode logmsg
smpl 1990 2050
eth_apd_ag = @recode(eth_apd_ag=NA,0,eth_apd_ag)
for !y = 2022 to 2050
smpl !y !y
if eth_apd_ag<0 then
logmsg failed for year !y
else
logmsg passed for year !y
endif
next


Method 2:

logmode logmsg
smpl 1990 2050
eth_apd_ag = @recode(eth_apd_ag=NA,0,eth_apd_ag)
for !y = 2022 to 2050
smpl 1990 2050
%sname = "Ser" + @str(!y)
series {%sname} = @recode(eth_apd_ag>0,1,0)
smpl !y !y
if {%sname}=0 then
logmsg failed for year !y
else
logmsg passed for year !y
endif
next

Re: How to run the program for Sampled year only and get result

Posted: Wed Jan 17, 2018 9:26 am
by EViews Gareth
You can't use a series in an if condition.

You can use the max of a series in an if condition.

Re: How to run the program for Sampled year only and get result

Posted: Wed Jan 17, 2018 11:23 pm
by nidhijain
But in that case as well,how to check data only for sample years, like i want to check data for only 2022 to 2050. But each time i put a check, it runs on the entire set of data and not on sample years and gives pass or fail according to that.

Re: How to run the program for Sampled year only and get result

Posted: Thu Jan 18, 2018 12:01 am
by EViews Gareth
Set the sample to the year you want, then check whether the maximum of the series is >0

Re: How to run the program for Sampled year only and get result

Posted: Thu Jan 18, 2018 10:22 pm
by nidhijain
Thanks a lot. It is working now. :D