Excel File Output Question

For questions regarding programming in the EViews programming language.

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

ron spencer
Posts: 1
Joined: Thu Jun 21, 2012 12:41 pm

Excel File Output Question

Postby ron spencer » Thu Jun 21, 2012 3:47 pm

I have a loop running that extracts data from 35 different regions for 50 years. It then saves to 35 different excel files (one for each region). However, is it possible to send this data to ONE excel file. Specifically, after each loop, APPEND the new data the the excel file without overwriting the old data. After all 35 parts of the loop, there will be one file with all the data.

Thanks.

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

Re: Excel File Output Question

Postby EViews Gareth » Thu Jun 21, 2012 4:05 pm

Unfortunately not.

rajiv
Posts: 5
Joined: Fri Aug 03, 2012 10:49 pm

Re: Excel File Output Question

Postby rajiv » Thu Aug 30, 2012 1:04 am

I have a similar question:

I am running a 25 different regressions on 50 products.
The 50 products data are stored in 50 different xls files.

I want to know if i can open an xls file and append results to that file using the output command. As per the documentation the output(v) command should append data to an existing file, however I find that the output(v) command overwrites the previous value, so only the last command is stored there.

Here is the logic i am using at a high level

For every xls file (i.e. unique product family) in the current directory
Run regressions 1 through 25
If regression 1, open file "regression_1_results) and store the results for this product family
If regression 2, open file "regression_2_results) and store the results for this product family
and so on till regression 25

If i use the output(v) command, then i find that I am able to only get the resutls for regression_25, all the previous values are overwritten.
Is there a way to make sure that the output(v) command if issued the 2nd time around does not overwrite an existing file?

thanks,
Rajiv

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

Re: Excel File Output Question

Postby EViews Gareth » Thu Aug 30, 2012 8:01 am

Code: Select all

create u 100 series y=nrnd series x=nrnd output(v) c:\temp\test equation eq1.ls(p) y c x equation eq2.ls(p) x c y
Works for me

rajiv
Posts: 5
Joined: Fri Aug 03, 2012 10:49 pm

Re: Excel File Output Question

Postby rajiv » Thu Aug 30, 2012 8:46 am

hi gareth thanks for the quick response.

can you double check this logic for the code snippet below?

Basically after i run the program, i want to see in the file equation_1.csv, the results for all the data sets for each file.
however i see only the results for the last file.
since i'm using the output(v) command to open the same csv file multiple times, it does not seem to append the results.

Finally i use the print command a lot, to print variable names, tables etc to the csv file. Not sure if that causes the file to be overwritten instead of the data getting appended

'FOR EQUATION 1 through 25
for j = 1 to 25
'FOR EVERY FILE IN THE DIRECTORY
for i=1 to no_of_files
'EXTRACT THE FILE NAME
string a_file_name = @word(myfiles, i)
tmp_storage(i) = a_file_name
'open the first data file
wfopen(a_file_name)
if j = 1 then
'RUN THE RESULTS FOR EQUATION 1
output(v) "C:\EViews\Results\equation_1.csv"
print results
'-----
if j = 2 then
'RUN THE RESULTS FOR EQUATION 1
output(v) "C:\EViews\Results\equation_2.csv"
print results

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

Re: Excel File Output Question

Postby EViews Gareth » Thu Aug 30, 2012 9:02 am

I do not think you can switch output files like that.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests