Page 1 of 1


Posted: Thu Mar 21, 2019 9:12 am
by tvonbrasch

Why is the code below generating an error? I thought the @iif command only does the calculation if a is not equal to 0...?

I have been inspired by the code in forum post viewtopic.php?f=5&t=10303&p=36003&hilit=splice#p36003. However, many of my "a"-series hold zero values and are thus creating these error messages. what is the best way of overcoming this problem?


Skjermbilde.PNG (9.25 KiB) Viewed 844 times

Code: Select all

wfcreate q 1970 2020

smpl @first 2000
   genr b=na
   genr a=0

smpl 2000 @last
   genr b=2.5

smpl @all


%if =%first + " " +%first
genr aux=@iif(a<>0, @mean(b,%if)/@mean(a,%if)*a,b)

Re: @iif

Posted: Thu Mar 21, 2019 9:20 am
by EViews Gareth
I don't get an error message if I run that code.

But, note, a test of a<>0 will return "na" if a=na, and so the @iif will return NA whenever a=na.