A question about ODBC.

For questions regarding programming in the EViews programming language.

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

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

A question about ODBC.

Postby Liu » Wed Mar 19, 2014 12:13 pm

Hi,

I met a program with Eviews 8 ODBC functionality. When I try to use Eview to query an external database, Eviews always pops a window/dialog frame for the results.
My question is: is there a way to store result of a query into a string variable, and saved it in a workfile, or the current workfile? The window is really causing me some trouble.

Thank you in advance.

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

Re: A question about ODBC.

Postby EViews Gareth » Wed Mar 19, 2014 12:17 pm

How are you performing the query? What is the dialog that pops up?

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: A question about ODBC.

Postby Liu » Wed Mar 26, 2014 7:20 am

Basically the query is performed by connecting to an external SQL server.
I will try to provide more information once I finish trials on my side.

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

Re: A question about ODBC.

Postby EViews Steve » Mon Mar 31, 2014 8:15 am

Let me suggest you read this post on how to import data from ODBC datasources. Basically, if you provide enough information for the import and/or run the import in an EViews program, the dialog will not appear...

http://forums.eviews.com/viewtopic.php?f=3&t=28

Steve

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: A question about ODBC.

Postby Liu » Tue Apr 15, 2014 6:37 am

Hi Steve and Gareth, thank you for your reply.

I have tried to access the SQL by following the instructions from Steve's last post.
However I don't know why I can not fetch or export the real series stored in the SQL, but only the columne names.

I have attached 5 screen shots for your reference. From the 4th screen shot it's obvious that there are 718 series in the database, but when I click "finish",
what's imported in the workfile is columne names, not the series themselves.

Which step is wrong?
Attachments
Desktop.rar
(820 KiB) Downloaded 488 times

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

Re: A question about ODBC.

Postby EViews Steve » Tue Apr 15, 2014 7:51 am

Liu:

EViews treats a single table as a collection of series objects, one series for each column, and we can only import one table at a time. So our expected table format looks like this:

Code: Select all

table1: col_date | series_1 | series_2 | series 3 ------------------------------------------ 1/1/14 | 1.0 | 2.0 | 3.0 2/1/14 | 1.1 | 2.2 | 3.1
If you store your data differently, you have to write your own query to re-shape your data into the table format I just described. It appears that your vwComFutureRates table is stored in a flat format where multiple series and their observations are stored as individual rows. My guess is that each series is tagged with an ID (series_id) and each ID has a date (series_value_date) and a value (series_value_val). Multiple rows of the same series_id store the other date/value pairs.

So you could write a query like this one to get your data back into the proper format (and import one series at a time):

Code: Select all

select series_value_date, series_value_val as series_1 from vwComFutureRates where series_id = 1 order by series_value_date
I realize this is only helpful if you know which series objects to import and they don't change over time.

You might also be able to just import the entire table as you have it, but then perform a panel conversion or unstack within EViews, but I'm not the one to talk about that. I'll leave that to Gareth.

Steve


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests