简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM