Assigning string variable to matrix element

For questions regarding programming in the EViews programming language.

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

Posts: 23
Joined: Tue Oct 21, 2014 2:44 pm

Assigning string variable to matrix element

Postby ral » Tue Feb 24, 2015 9:07 am


Is it possible to assign a string variable to an element in a matrix?

The code fragment that I have written is below. I would like the output to be a 7xN matrix (N=2 in the fragment below) where the top row contains the names of the variables in the group (i.e., EURUSD and USDJPY) and the rows of the matrix contain statistics obtained from the regression (i.e., bhat) for each variable.

As it is written now, the code returns the error: Syntax error in "XRATES_RESULTS(1,1)="

Thank you.

group xrates_g EURUSD USDJPY
scalar N = xrates_g.@count
matrix(7,N) xrates_results

for !i=1 to N

genr dl{%x}=100*(log({%x})-log({%x}(-1)))
equation {%x}"hac") dl{%x} c dussw2
alpha sername=%x
xrates_results(1,!i) = 'sername'
xrates_results(2,!i) = c(2)


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

Re: Assigning string variable to matrix element

Postby EViews Gareth » Tue Feb 24, 2015 9:13 am

Matrices can only hold numbers. If you really want to hold text and numbers, use a table.
Follow us on Twitter @IHSEViews

EViews Glenn
EViews Developer
Posts: 2615
Joined: Wed Oct 15, 2008 9:17 am

Re: Assigning string variable to matrix element

Postby EViews Glenn » Tue Feb 24, 2015 10:34 am

This may not be enough for your needs, but you can set row labels for a matrix using the setrowlabels matrix proc. These labels are not a part of the matrix.

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests