Mapping N/A values to a new value

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

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

dravenous
Posts: 33
Joined: Thu Jan 29, 2015 2:30 pm

Mapping N/A values to a new value

Postby dravenous » Fri Feb 06, 2015 8:59 am

Hello there. This is probably something ridiculously simple. I am trying to replace missing data points within multiple series with a new value generated off the last year's growth rate. So if I am missing 2014q3 I take the growth rate from 2013q2-2013q3 and use that to interpolate the 2014q3 value. I am trying to use the code below, but I think that I am referencing the series wrong. I want it to check through and if there is no NA leave the series as is, but if there is an NA fill the NA with a value calculated as mentioned above. I also tried to use the second code, but to no avail. The second code I would also have to put into a for statement for all of the states, I was just testing if it would work for Ohio. Thanks! Edit: The first one gives the error message "NA found in matrix in "IF NGPIND{%X} = NA THEN" in testfill.prg.

Code: Select all

%states = "AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY" for %x {%states} if ngpind{%x} = na then series ngpind{%x} = ((ngpind{%x}(-4)-ngpind{%x}(-5))/ngpind{%x}(-5))*ngpind{%x} else ngpind{%x}=ngpind{%x} endif next

Code: Select all

series ngpindoh = @nan(ngpindoh, ((ngpindoh(-4)-ngpindoh(-5))/ngpindoh(-5))*ngpindoh)

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

Re: Mapping N/A values to a new value

Postby EViews Gareth » Fri Feb 06, 2015 9:24 am

Surely you want to multiply the growth rate by the previous value, not the current one (which is an NA).

Also,
http://forums.eviews.com/viewtopic.php?f=5&t=3765

dravenous
Posts: 33
Joined: Thu Jan 29, 2015 2:30 pm

Re: Mapping N/A values to a new value

Postby dravenous » Fri Feb 06, 2015 9:44 am

Yea you are correct about wanting to multiply it by the previous value. The @recode is working much better. Thanks.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests