Using a string list to set matrix labels
Posted: Tue Nov 22, 2016 10:49 am
Hi,
I am importing a weight matrix from Excel which have headers in both columns and rows. I want to import them together with the values but from what I have gathered it is not possible. I have followed this post (http://forums.eviews.com/viewtopic.php?t=11036), and copied the labels in a svector from a new page. From there, I convert them to a string list object as I thought I could use it to add the labels with the command setrowlabels and setcollables but I am missing something as I can't manage it. Please see the code below:
matrix mat1
mat1.import path range= wmatrix!b2
pageload(page="weights") path range=wmatrix ' Imports weights matrix into new page "weights"
svector sv_cc=@convert(ctry_codes) ' transforms ctry_codes into a string vector
copy weights\sv_cc sv_cc 'copies the string vector in the default page
string str_cc=@wjoin(sv_cc) ' converts the svector into a string
The content in str_cc looks like this: CAN GBR JPN USA DEU ITA FRA.
When I manually copy and paste this list into setrowlabels it works. However, I have been trying to use the string object as below, but I don't know what the right coding is. I have been searching through the forums but I can't find any reference. Can you help please?
%c = {str_cc}
mat1.setcollabels {%c}
Best,
Marta
I am importing a weight matrix from Excel which have headers in both columns and rows. I want to import them together with the values but from what I have gathered it is not possible. I have followed this post (http://forums.eviews.com/viewtopic.php?t=11036), and copied the labels in a svector from a new page. From there, I convert them to a string list object as I thought I could use it to add the labels with the command setrowlabels and setcollables but I am missing something as I can't manage it. Please see the code below:
matrix mat1
mat1.import path range= wmatrix!b2
pageload(page="weights") path range=wmatrix ' Imports weights matrix into new page "weights"
svector sv_cc=@convert(ctry_codes) ' transforms ctry_codes into a string vector
copy weights\sv_cc sv_cc 'copies the string vector in the default page
string str_cc=@wjoin(sv_cc) ' converts the svector into a string
The content in str_cc looks like this: CAN GBR JPN USA DEU ITA FRA.
When I manually copy and paste this list into setrowlabels it works. However, I have been trying to use the string object as below, but I don't know what the right coding is. I have been searching through the forums but I can't find any reference. Can you help please?
%c = {str_cc}
mat1.setcollabels {%c}
Best,
Marta