Page 1 of 1

Syntax Error in seemingly identical code?

Posted: Wed Apr 08, 2015 6:01 pm
by dravenous
I am writing some code and it keeps giving me a syntax error when I don't believe that I should be getting one. I took a small portion of the first program that I wrote below. This code works fine, but for some reason the second iteration fails.

Code: Select all

series histwa{%st} = ((wa{%st}/wa{%st}(-!h1))^(4/!h1)-1)*100 - ((gwa{%st}/gwa{%st}(-!h1))^(4/!h1)-1)*100 series forewa{%st} = ((wa{%st}/wa{%st}(-!f1))^(4/!f1)-1)*100 - ((gwa{%st}/gwa{%st}(-!f1))^(4/!f1)-1)*100 series carn{%st} = ((wa{%st}/wa{%st}(-!f1))^(4/!f1)-1)*100
However the code that follows here is a no go.

Code: Select all

!h1=@dtoo(%a)-@dtoo(%sd) for %z {%metro} series CAR{%0}{%z}_{%sim} = (({%0}{%z}_1/({%0}{%z}_1)(-!h1))^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old1} = (({%0}{%z}_{%old1}/({%0}{%z}_{%old1})(-!h1))^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old2} = (({%0}{%z}_{%old2}/({%0}{%z}_{%old2})(-!h1))^(4/!h1)-1)*100) next
Specific error shown below. eeboro_1 is a series located within my workfile, so there is no issue there. I assume the error lies with the lag, but the first set of code used a similar technique so I am unsure where the mistake follows.
Image

Re: Syntax Error in seemingly identical code?

Posted: Thu Apr 09, 2015 4:06 am
by EViews Gareth

Code: Select all

({%0}{%z}_1)(-!h1))
has extra parenthesis

You probably want

Code: Select all

{%0}{%z}_1(-!h1))

Re: Syntax Error in seemingly identical code?

Posted: Thu Apr 09, 2015 6:08 am
by dravenous
Wow, thanks Gareth. What a sensitive thing. I didn't think they would make a difference. Doesn't this mess up the order of operations? I need to raise the (A/B)^(-!h1)

Code: Select all

for %z {%met} series PCD{%0}{%z}_{%old1}= (({%0}{%z}_1-{%0}{%z}_{%old1})/({%0}{%z}_{%old1}))*100 series PCD{%0}{%z}_{%old2} = (({%0}{%z}_1-{%0}{%z}_{%old2})/({%0}{%z}_{%old2}))*100 series CAR{%0}{%z}_{%sim} = (({%0}{%z}_1/{%0}{%z}_1(-!h1)^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old1} = (({%0}{%z}_{%old1}/{%0}{%z}_{%old1}(-!h1)^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old2} = (({%0}{%z}_{%old2}/{%0}{%z}_{%old2}(-!h1)^(4/!h1)-1)*100) next

Re: Syntax Error in seemingly identical code?

Posted: Thu Apr 09, 2015 6:35 am
by dravenous
It seems that the only way to get the correct growth rate, is to use the code below as opposed to what I mentioned earlier. Rather clunky work around, unfortunately.

Code: Select all

for %z {%met} series cheat1 = {%0}{%z}_1/{%0}{%z}_1(-!h1) series cheat2 = {%0}{%z}_{%old1}/{%0}{%z}_{%old1}(-!h1) series cheat3 = {%0}{%z}_{%old2}/{%0}{%z}_{%old2}(-!h1) series PCD{%0}{%z}_{%old1}= (({%0}{%z}_1-{%0}{%z}_{%old1})/({%0}{%z}_{%old1}))*100 series PCD{%0}{%z}_{%old2} = (({%0}{%z}_1-{%0}{%z}_{%old2})/({%0}{%z}_{%old2}))*100 series CAR{%0}{%z}_{%sim} = ((@elem(cheat1, %a)^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old1} = ((@elem(cheat2, %a) ^(4/!h1)-1)*100) series CAR{%0}{%z}_{%old2} = ((@elem(cheat3, %a)^(4/!h1)-1)*100) next

Re: Syntax Error in seemingly identical code?

Posted: Thu Apr 09, 2015 12:55 pm
by EViews Gareth
I don't understand your point. You can do the calculations in exactly the same way you did them before. In the faulty code, you had added parenthesis over the first original code. Those parenthesis are what caused the problem.

Re: Syntax Error in seemingly identical code?

Posted: Thu Apr 09, 2015 12:58 pm
by EViews Gareth
To make it more clear:

series histwa{%st} = ((wa{%st}/wa{%st}(-!h1))^(4/!h1)-1)*100
series stuffssssssss = (({%0}{%z}_1/({%0}{%z}_1)(-!h1))^(4/!h1)-1)*100)