@iif

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

tvonbrasch
Posts: 540
Joined: Fri Apr 15, 2011 5:35 am

@iif

Postby tvonbrasch » Thu Mar 21, 2019 9:12 am

Hi

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?

Thomas



Skjermbilde.PNG
Skjermbilde.PNG (9.25 KiB) Viewed 2588 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

%first=b.@first

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13308
Joined: Tue Sep 16, 2008 5:38 pm

Re: @iif

Postby EViews Gareth » Thu Mar 21, 2019 9:20 am

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.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 15 guests