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!
COM Automation for ARMA
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: COM Automation for ARMA
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
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?
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?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: COM Automation for ARMA
I'm not sure I follow. WFSAVE saves the current workfile.
Re: COM Automation for ARMA
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...
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...
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: COM Automation for ARMA
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.
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.
Who is online
Users browsing this forum: No registered users and 2 guests
