IF Statement on a Variable Name

For questions regarding programming in the EViews programming language.

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

BCNAV
Posts: 40
Joined: Tue Oct 31, 2017 9:06 am

IF Statement on a Variable Name

Postby BCNAV » Fri Nov 17, 2017 8:17 am

I have:

Code: Select all

%vars="ovr_amt_m11 ovr_amt_m14 ovr_amt_m22 ovr_amt_m23 ovr_amt_ktk ovr_amt_oth ter_amt_m11 ter_amt_m22 ter_amt_m33 ter_amt_m34 ter_amt_m35 enr_amt_m11 enr_amt_m22 enr_amt_m33 enr_amt_m34 enr_amt_m35"

genr overflight = ovr_amt_m11+ovr_amt_m14+ovr_amt_m22+ovr_amt_m23+ovr_amt_ktk+ovr_amt_oth
genr terminal = ter_amt_m11+ter_amt_m22+ter_amt_m33+ter_amt_m34+ter_amt_m35
genr enroute = enr_amt_m11+ enr_amt_m22+enr_amt_m33+enr_amt_m34+enr_amt_m35

for %series {%vars}
   if @left({%series},3)="ovr" then
      {%series}_shr={%series}/overflight
   endif
next


I would like the IF statement within the loop to check if the first 3 characters of the VARIABLE NAME contain something. In the case here, those first three are "ovr". If true, execute some statements. This does not work as EViews is looking at variables within the variable, asopposed top the variable name. How does one refer to characters within the variable name?

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

Re: IF Statement on a Variable Name

Postby EViews Gareth » Fri Nov 17, 2017 8:21 am

Remove the braces
Follow us on Twitter @IHSEViews

BCNAV
Posts: 40
Joined: Tue Oct 31, 2017 9:06 am

Re: IF Statement on a Variable Name

Postby BCNAV » Fri Nov 17, 2017 9:26 am

I ended up messing around and found:

Code: Select all

   if @left(({%series}.@name),3)="OVR"


I didn't realize that if I removed the braces it would be good. Thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 34 guests