Page 1 of 1

Assigning string variable to matrix element

Posted: Tue Feb 24, 2015 9:07 am
by ral
Hi,

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

%x=xrates_g.@seriesname(!i)
genr dl{%x}=100*(log({%x})-log({%x}(-1)))
equation {%x}eq.ls(cov="hac") dl{%x} c dussw2
alpha sername=%x
xrates_results(1,!i) = 'sername'
xrates_results(2,!i) = c(2)

next

Re: Assigning string variable to matrix element

Posted: Tue Feb 24, 2015 9:13 am
by EViews Gareth
Matrices can only hold numbers. If you really want to hold text and numbers, use a table.

Re: Assigning string variable to matrix element

Posted: Tue Feb 24, 2015 10:34 am
by EViews Glenn
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.