How to import data from EViews to MATLAB directly (without writing anything to disk)

614 views Asked by At

I would like to import data from an EViews (point-and-click econometric software which I am regrettably forced to use) database directly into MATLAB without writing any temporary files to disk. Of course it is straightforward to export a series to CSV or Excel and import it into MATLAB subsequently, but this is inefficient for a large number of series, and it doesn't permit automation.

1

There are 1 answers

0
transversality condition On BEST ANSWER

This is covered in a document on the EViews web site: Eviews COM Automation. From MATLAB, create a handle to an ActiveX control and use that to pass the data back and forth in memory.

% launch EViews ActiveX server
hm = actxserver('Eviews.Manager') ;
h = hm.GetApplication(0) ;

% load file
h.Run(sprintf('wfuse %s',myPath)) ;

% dates
h.Run(sprintf('string startDate = %s.@first',myVar)) ;
startDate = h.Get('startDate') ;
h.Run(sprintf('string endDate = %s.@last',myVar)) ;
endDate = h.Get('endDate') ;

% drop consecutive leading/trailing missing observations
h.Run(sprintf('smpl %s %s',startDate,endDate)) ;

% transfer values
values = cell2mat(h.GetSeries(myVar)) ;

h.release ;

Note that there is some start-up time because one must wait for Eviews to launch in the background before it can be used, so if you want to import multiple series it would be advisable to insert the loop after the creation of the handle to the ActiveX control.

Also note that this does not work with all versions of Eviews. If you have difficulty, first contact the manufacturer to obtain a patch.