Retrieving a String from Excel?

For questions regarding programming in the EViews programming language.

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

ttocont
Posts: 7
Joined: Mon Aug 26, 2013 7:42 am

Retrieving a String from Excel?

Postby ttocont » Mon Aug 26, 2013 7:58 am

Hello. I am trying to speed up the process of filling the strings in a set of programs I have in Eviews 7. Is there a way to fill a string in a program by wfopen/anything else from an Excel 2010 .xlsx file as you would with normal series?

For example, if I have a columns in Excel like this?

%vars1 %vars2
a q
b f
c d
d t
e u
f m
g g

Is there a way of filling string values from Excel rows/columns so they could be used in the Eviews program as:
%vars1 = "a b c d e f g"
%vars2 = "q f d t u m g"

Thanks

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

Re: Retrieving a String from Excel?

Postby EViews Gareth » Mon Aug 26, 2013 8:03 am

You'll have to create a new page, 7 observations long, read them both in as Alpha series, then convert the Alpha series into string variables (looping through the observations one at a time). Painful.

ttocont
Posts: 7
Joined: Mon Aug 26, 2013 7:42 am

Re: Retrieving a String from Excel?

Postby ttocont » Mon Aug 26, 2013 2:02 pm

Thanks for the help. At least I know I'm not missing the simple option. The @elem would work without too much pain I would think, unless it can't handle alpha series? I thought of something like the below on the way home and was going to try it out when I'm back (using @ilast in the loop as the elements in the alpha series I need in the string change in length and are all different lengths).

alpha vars1
For !j=1 to @ilast(vars1)
%vars1 elem(vars1,{!j})
next

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

Re: Retrieving a String from Excel?

Postby EViews Gareth » Mon Aug 26, 2013 2:15 pm

I don't think Alphas have an @ilast.

This would work, assuming you don't have blanks in the middle of each alpha:

Code: Select all

for !I=1 to @obsrange %temp = a(!i) if @len(%temp) then %vars1 = %vars1 + " " + %temp else exitloop endif next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests