Importing complex Excel files

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

CecileBF
Posts: 11
Joined: Mon Mar 27, 2023 8:54 am

Importing complex Excel files

Postby CecileBF » Fri Apr 05, 2024 6:33 am

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.

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Importing complex Excel files

Postby EViews Steve » Fri Apr 05, 2024 7:48 am

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

CecileBF
Posts: 11
Joined: Mon Mar 27, 2023 8:54 am

Re: Importing complex Excel files

Postby CecileBF » Mon Apr 08, 2024 1:50 am

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 ?

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Importing complex Excel files

Postby EViews Steve » Mon Apr 08, 2024 10:14 am

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 278 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
Attachments
prob.prg
(786 Bytes) Downloaded 7 times

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Importing complex Excel files

Postby EViews Steve » Mon Apr 08, 2024 10:47 am

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 275 times

Steve
Attachments
prob.prg
(836 Bytes) Downloaded 9 times


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 8 guests