Flow control with string variables

For questions regarding programming in the EViews programming language.

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

londonphd
Posts: 37
Joined: Fri Oct 23, 2015 11:39 am

Flow control with string variables

Postby londonphd » Thu May 12, 2016 11:24 am

Hello,

Transition from R to Eviews programming has been a little painful, hope someone will help with the following question:

Code: Select all

string xd=deter(!i) if %xd="trend" then %xd="d" else %xd="b" endif
here deter is a "string vector", its elements are either "trend" or "cons". I ran the code and it appeared to work, but then the results did not appear to be right.

Thank you.

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

Re: Flow control with string variables

Postby EViews Gareth » Thu May 12, 2016 12:03 pm

Well, XD and %XD are different things. It looks like you're assigning to XD, but testing %XD.

londonphd
Posts: 37
Joined: Fri Oct 23, 2015 11:39 am

Re: Flow control with string variables

Postby londonphd » Thu May 12, 2016 12:38 pm

Well, XD and %XD are different things. It looks like you're assigning to XD, but testing %XD.
Thanks Gareth, I corrected it, works flawlessly. I was following an example where "%" is used, just did not read the details properly.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest