Page 1 of 1
Excel File Output Question
Posted: Thu Jun 21, 2012 3:47 pm
by ron spencer
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.
Re: Excel File Output Question
Posted: Thu Jun 21, 2012 4:05 pm
by EViews Gareth
Unfortunately not.
Re: Excel File Output Question
Posted: Thu Aug 30, 2012 1:04 am
by rajiv
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
Re: Excel File Output Question
Posted: Thu Aug 30, 2012 8:01 am
by EViews Gareth
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
Re: Excel File Output Question
Posted: Thu Aug 30, 2012 8:46 am
by rajiv
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
Re: Excel File Output Question
Posted: Thu Aug 30, 2012 9:02 am
by EViews Gareth
I do not think you can switch output files like that.