Using a string list to set matrix labels

For questions regarding programming in the EViews programming language.

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

altaus
Posts: 20
Joined: Fri Jan 30, 2015 6:46 am

Using a string list to set matrix labels

Postby altaus » 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

EViews Matt
EViews Developer
Posts: 583
Joined: Thu Apr 25, 2013 7:48 pm

Re: Using a string list to set matrix labels

Postby EViews Matt » Tue Nov 22, 2016 1:03 pm

Hello,

You didn't mention which version of EViews you have, but try using the string object directly with setcollabels, i.e., mat1.setcollabels {str_cc}.

altaus
Posts: 20
Joined: Fri Jan 30, 2015 6:46 am

Re: Using a string list to set matrix labels

Postby altaus » Wed Nov 23, 2016 1:56 am

Great thanks! It works in eViews 9.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests