Page 1 of 1

COM Automation for ARMA

Posted: Tue Jun 26, 2012 10:00 am
by Rits
I am using COM Automation to run EViews from C#. I got the point of being able to start and run EViews from C# and calculate ARMA forecasts and save in a CSV file. The problem occurs when I try to read the CSV file. At times (not always) the CSV would store an NA for the forecast even though the value exists in EViews workfile. Since it happens sporadically I am unable to pinpoint the issue. Below is the code I am using:


EViews.Manager mgr = new EViews.Manager();
app = mgr.GetApplication(EViews.CreateType.NewInstance);
app.Run("wfopen C:\\EViews7\\ES.wf1");
app.Run("smpl @all");
app.Run("series temp = @recode(chg<>na, @trend,na)+1");
app.Run("scalar last = @max(temp)");
app.Run("string lastdate = @otod(last)");
app.Run("smpl {lastdate}-5000 {lastdate}");
app.Run("LS CHG C MA(1) MA(2)");

app.Run("smpl {lastdate}+1 {lastdate}+1");
app.Run("FORCST YHAT");
app.Run("Genr Forcst = YHAT");
app.Run("Save C:\\EViews7\\ES.wf1");
app.Run("Output(v) C:\\Users\\Public\\ES1.csv");
app.Run("Print(p) FORCST");
app.Run("output off");
app.Run("close @all");
rngForecast.Value = helper.ReadForecast(b1.InstName); //Function to read last value of EViews output file into excel cell


What am I missing here? Any help is much appreciated!

Thanks!

Re: COM Automation for ARMA

Posted: Tue Jun 26, 2012 10:06 am
by EViews Gareth
Better off just using the wfsave command to create the CSV file, rather than messing around with output and print statements.

Re: COM Automation for ARMA

Posted: Tue Jun 26, 2012 9:57 pm
by Rits
Thanks for the response. So I tried using wfsave to create a csv. My best guess was this:

app.Run("wfsave (t=csv) C:\\Users\\Public\\ES1.csv @all @keep FORCST")

But clearly the problem here is how do I specify the workfile from which CSV will pull FORCST series data?

Re: COM Automation for ARMA

Posted: Tue Jun 26, 2012 10:01 pm
by EViews Gareth
I'm not sure I follow. WFSAVE saves the current workfile.

Re: COM Automation for ARMA

Posted: Wed Jun 27, 2012 5:14 am
by Rits
I thought we could specify the format for the file to be saved.
So since it cannot be done, my question is, what's the best way to copy/move certain series(or even just the most latest value) from the workfile and save it in a csv??
I need to do this programatically in COM Automation. Basically I want to be able to read the value of the FORCST series once the ARMA calculations are done.

Thanks...

Re: COM Automation for ARMA

Posted: Wed Jun 27, 2012 7:48 am
by EViews Gareth
I'm now totally confused.

You want to save a series from your workfile into a CSV file. This is done with the wfsave command. It is done exactly how showed with your best guess.