Page 1 of 1

IF Statement on a Variable Name

Posted: Fri Nov 17, 2017 8:17 am
by BCNAV
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?

Re: IF Statement on a Variable Name

Posted: Fri Nov 17, 2017 8:21 am
by EViews Gareth
Remove the braces

Re: IF Statement on a Variable Name

Posted: Fri Nov 17, 2017 9:26 am
by BCNAV
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