Page 1 of 1

Importing complex Excel files

Posted: Fri Apr 05, 2024 6:33 am
by CecileBF
Hi,
I use Eviews 13 Enterprise. I am trying to import Excel files to extract values, in order to reconstruct at the end times series.
Basically, the structure looks like it:

Gross Domestic| |Household | |Gross Fixed
Product ||Consumption ||Investment
Prev 1 | Prev 2 | Prev 1 | Prev 2 | Prev 1 | Prev 2

4,296 | 2,205| 5,839 |2,221 |4,922 | 2,801

(each | indicates a column)
I try to import this by making six series: gross_domestic_product_year1, gross_domestic_product_prev2, household_consumption_prev1, household_consumption_prev2, gross_fixed_investment_prev1, gross_fixed_investment_prev2.
The issue is that the first two lines are on the cells of the left: so when I import, I have gross_domestic_product_prev1, prev2, household_consumption_year1, prev201, gross_fixed_investment_prev1, prev202.
If the names on the first two lines were duplicated above Prev2, there would be no problem.
Is there still a way to import my six series?
Regards.

Re: Importing complex Excel files

Posted: Fri Apr 05, 2024 7:48 am
by EViews Steve
No, there isn't a way to tell the import command to repeat values from previous cells when reading in the header lines.

I would recommend manually renaming the prev2 series objects after doing the import, like this:

Code: Select all

import... rename prev2 gross_domestic_product_prev2 rename prev201 household_consumption_prev2 rename prev202 gross_fixed_investment_prev2
Steve

Re: Importing complex Excel files

Posted: Mon Apr 08, 2024 1:50 am
by CecileBF
Thanks for your response. The issue is the fact there are a lot more variables than what I showed (so a lot of columns) so I try to find a way to do it automatically... Even with several steps. Do you have any suggestion ?

Re: Importing complex Excel files

Posted: Mon Apr 08, 2024 10:14 am
by EViews Steve
My suggestion is to perform a custom text manipulation before doing the import. You should do this in an external program (such as a custom batch script) as EViews is not designed to be an efficient text manipulation engine. But here's how you would do that using EViews code:
2024-04-08_10h00_08.png
2024-04-08_10h00_08.png (29.15 KiB) Viewed 43492 times
Since the first portion of this code (that performs the text manipulation) is loading the entire source file into memory, you may run into issues if you don't have enough RAM to do this. A custom script can avoid this.

Steve

Re: Importing complex Excel files

Posted: Mon Apr 08, 2024 10:47 am
by EViews Steve
I forgot you mentioned that the source file is an Excel spreadsheet. Here's the import statement you would need to use then:
prob2.png
prob2.png (27.7 KiB) Viewed 43489 times
Steve

Re: Importing complex Excel files

Posted: Fri May 30, 2025 5:11 am
by CecileBF
Dear Steve,
I forgot to say it: thanks A LOT for the response, I've done a similar program thanks to your advice and my problem is solved, it works perfectly well !