Syntax Error in seemingly identical code?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

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

Syntax Error in seemingly identical code?

Postby dravenous » Wed Apr 08, 2015 6:01 pm

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

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

Re: Syntax Error in seemingly identical code?

Postby EViews Gareth » Thu Apr 09, 2015 4:06 am

Code: Select all

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

You probably want

Code: Select all

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

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

Re: Syntax Error in seemingly identical code?

Postby dravenous » Thu Apr 09, 2015 6:08 am

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

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

Re: Syntax Error in seemingly identical code?

Postby dravenous » Thu Apr 09, 2015 6:35 am

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

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

Re: Syntax Error in seemingly identical code?

Postby EViews Gareth » Thu Apr 09, 2015 12:55 pm

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.

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

Re: Syntax Error in seemingly identical code?

Postby EViews Gareth » Thu Apr 09, 2015 12:58 pm

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)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest