Excel Add-In

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

cmgconsulting
Posts: 38
Joined: Mon Nov 17, 2008 8:25 am

Excel Add-In

Postby cmgconsulting » Mon Apr 26, 2010 8:50 am

When I'm importing data into Excel from an EViews database using the Excel Add-in , is there any way to only pull a subset of a database w/o using the date. For example, if I have a series called "STATE", can I say "if state="TEXAS"" to only pull the rows where this condition is met? I'm using EViews 7.1.
Last edited by cmgconsulting on Mon Apr 26, 2010 8:53 am, edited 1 time in total.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13319
Joined: Tue Sep 16, 2008 5:38 pm

Re: Excel Add-In

Postby EViews Gareth » Mon Apr 26, 2010 8:53 am

Just to be clear, are you importing data into Excel from EViews using the Excel Add-in (as would be indicated by your thread title), or are you importing data into EViews from Excel (as would be indicated by your phrase "importing data from Excel")?
Follow us on Twitter @IHSEViews

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13319
Joined: Tue Sep 16, 2008 5:38 pm

Re: Excel Add-In

Postby EViews Gareth » Mon Apr 26, 2010 8:54 am

Nevermind, saw you just edited your post :D
Follow us on Twitter @IHSEViews

cmgconsulting
Posts: 38
Joined: Mon Nov 17, 2008 8:25 am

Re: Excel Add-In

Postby cmgconsulting » Mon Apr 26, 2010 8:54 am

Sorry, INTO Excel from an EViews database

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Excel Add-In

Postby EViews Steve » Mon Apr 26, 2010 9:22 am

The EViews Excel Add-In uses the new EViews OleDb driver to access data from an EViews workfile or database. This OLEDB driver has some limitations as it doesn't have access to the entire EViews functional library to do things like filter rows based on values from other series, etc. The most it can do is allow you to specify the date ranges of the sample you'd like to read. You can't use named sample objects or conditional samples like you're trying to do.

I would suggest you use EViews COM Automation instead of the Excel Add-In. COM Automation allows client programs (such as Excel) to launch EViews in the background (via COM) and you can open workfiles and read in the exact data observations that you want (using GetData calls). This interface also allows you to write back to the workfile (using PutData calls) and save the changes. The limitation of this approach is that you have to run EViews itself in the background, which takes more resources than the smaller OLEDB driver. Another limitation is that we do not allow you to use EViews COM Automation from a web server -- and when running as a windows service (or via Distributed COM), you are limited to only running a single instance of EViews at a time per machine.

You can read up on how to use COM Automation by downloading our whitepaper here (it also contains examples of using COM Automation from Excel): http://eviews.com/download/whitepapers/ ... mation.pdf

Steve

guyspy
Posts: 3
Joined: Tue Feb 08, 2011 7:46 am

Re: Excel Add-In

Postby guyspy » Tue Feb 08, 2011 8:51 am

Hi, I'm new to using the com side to export series from Eviews 7 into excel. Using the code provided (read with errror handling) at the end of the white paper above, is there a simple way to include the dates associated with the series exported? Apologies if this is a simple question. Many thanks!

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Excel Add-In

Postby EViews Steve » Tue Feb 08, 2011 9:32 am

The series "@DATE" is a built-in series that will return the frequency values of the current workfile, whether that be dates, undated integers, etc.

You can modify the GetWorkfile (Read with Error Handling) method in the COM Automation Whitepaper example by first calling:

Code: Select all

seriesData = app.GetSeries("@data", "@all")

and then displaying this single column of dates in it's own Excel column before calling:

Code: Select all

seriesData = app.GetGroup(columnHeaders, "@all")


Steve

guyspy
Posts: 3
Joined: Tue Feb 08, 2011 7:46 am

Re: Excel Add-In

Postby guyspy » Tue Feb 08, 2011 11:10 am

Thanks Steve. It appears to be in a row format rather than a column. Is there a simple way to transpose the dates, or should I just do it through the traditional excel VBA method? Thanks again

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Excel Add-In

Postby EViews Steve » Tue Feb 08, 2011 11:45 am

The GetSeries call returns a 1-dimensional array. So you can display this as a row or a column, your choice. For example, if you have a workfile with 10 observations (from 1991 to 2000):

Code: Select all

Dim obj1 as Object = app.GetSeries("@date")


will return the data in this format:
obj1(0) = 1991
obj1(1) = 1992
etc...

The GetGroup call returns a 2-dimensional array (as long as you specify multiple series objects to return). It always returns the data rows as the first index, followed by the column index. For example, if you have a workfile with 10 observations with a series named X and Y:

Code: Select all

Dim obj2 as Object = app.GetGroup("@date x y", "@all")


the data is returned in array form like this:

Code: Select all

         @date      X           Y
         col 0      col 1       col 2
row 0    1991       0.293838    32.398283
row 1    1992       0.594843    39.395495


So obj2(0,1) would be 0.293838.

We don't provide any utility functions to transpose the data into the other format (cols first, then rows). You'll have to use your own function to do this.

Steve

guyspy
Posts: 3
Joined: Tue Feb 08, 2011 7:46 am

Re: Excel Add-In

Postby guyspy » Tue Feb 08, 2011 12:14 pm

Thanks for your help Steve!


Return to “General Information and Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 22 guests