VBA to Eviews

For questions regarding programming in the EViews programming language.

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

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

VBA to Eviews

Postby Elderfield.A » Mon Jun 22, 2020 6:23 pm

Hi,

I am writing some VBA to take data from excel into eviews:

Code: Select all


Dim shReadMe  As Worksheet, shWorkingAdd As Worksheet
    Dim mgr As New EViews.Manager
    Dim app As EViews.Application
    Dim Path As String, SeriesName As String
    Dim rngAdjustedProfile As Range
       
    Set shReadMe = Worksheets("READ ME")
    Set shWorkingAdd = Worksheets("Working AddFactors")
    Set app = mgr.GetApplication(ExistingOrNew)
    Path = shReadMe.Range("PATH")
    Set rngAdjustedProfile = shWorkingAdd.Range("Q8:X8")
    SeriesName = shWorkingAdd.Range("VARIABLE")
   
   
    app.Run "wfopen """ & Path & "\output\Model.wf1"""
    app.Run "smpl 2020q2 2022q2"
    app.Put SeriesName, rngAdjustedProfile, DataTypeSeries
    app.Show




Everything works, except the app.put call doesnt seem to read in the range of data, but only the first observation, so in this instance the data in cell Q8 in shWorkingAdd. I have changed the cell reference and every time it is the same, reading in only the first observation in the range - NAs for everything else.

I also have tried app.PutSeries with no avail.

I am using Eviews 10+ and Excel 2016.

Any thoughts as to where I am going wrong?

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: VBA to Eviews

Postby Elderfield.A » Mon Jun 22, 2020 8:42 pm

Turns out this is happening because my range runs across columns. It appears that for this to work I need the data to be transposed:

I have changed this

Code: Select all

Dim rngAdjustedProfile As Variant, rngAdjustedProfileT as Variant


And this

Code: Select all

rngAdjustedProfile = shWorkingAdd.Range("AdjustedProfile").Value2
rngAdjustedProfileT = Application.Transpose(rngAdjustedProfile)


Which seems to work!

However, I would be interested to know if this was indeed the issue, and if there is a better work around?

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

Re: VBA to Eviews

Postby EViews Steve » Tue Jun 23, 2020 7:09 am

EViews reads and writes a series object vertically. So transpose is the solution we recommend to people who have their data running horizontally.

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

Re: VBA to Eviews

Postby EViews Gareth » Tue Jun 23, 2020 8:52 am

EViews Steve wrote:EViews reads and writes a series object vertically. So transpose is the solution we recommend to people who have their data running wrongly.


Fixed that for you.
Follow us on Twitter @IHSEViews

Elderfield.A
Posts: 41
Joined: Thu Jul 11, 2019 10:47 pm

Re: VBA to Eviews

Postby Elderfield.A » Tue Jun 23, 2020 4:11 pm

Thanks for the useful responses Steve and Gareth - personal opinions around which way data should run when people set up spreadsheets aside, it would be a nice feature to have in future. I also couldn't find any reference to this little quirk in the white paper (although I could have missed it) - are there any other quirks that are not documented that would be useful to know?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 14 guests