Chicagofed data import into eviews

For questions regarding programming in the EViews programming language.

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

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Chicagofed data import into eviews

Postby salahaddin » Thu Dec 11, 2014 7:23 am

Hello everyone,

I am trying to replicate the estimation in one Article which is available at this link:

http://ssrn.com/abstract=2519503

The data for the Article was taken from the Chicagofed website:

https://www.chicagofed.org/banking/fina ... -bank-data

I need to take the complete data from 1976-2000 (which is quarterly and are in separate files for each quarter of each year for all banks of chicago) and extract observations only for two banks (entity value of 1st bank=128258 and of 2nd bank=403656), and then transform the data from quarterly to annual. It is very time consuming to do it one by one. I wonder is there any code or any program in eviews which can help me to do it easier?

Thanks in advance.

rousing
Posts: 77
Joined: Fri Jun 11, 2010 5:56 am
Location: Switzerland

Re: Chicagofed data import into eviews

Postby rousing » Fri Dec 12, 2014 6:32 am

I would do the downloading and unzipping in powershell, attached below some code which more or less does this with the CFTC data. The Eviews import can also be done dynamically by creating the import files dynamically (not done in the code below since I only have 3 fixed name excel sheets).

Code: Select all

# COPY FILES WITH DYNAMIC NAMES FROM THE INTERNET ############ CFTC ################################ $userAgent="Mozilla/4.0 (compatible; MSIE 6.0; windows NT 5.2;)" $wc = New-Object System.Net.WebClient $wc.Headers.Add("user-agent",$userAgent) $wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials $coresource="http://www.cftc.gov" $sourcepage="http://www.cftc.gov/MarketReports/CommitmentsofTraders/HistoricalCompressed/index.htm" $webpagetxt = "C:\Database\ExternalSources\cftc.txt" $webpage=$wc.DownloadString($sourcepage) $webpage > "$webpagetxt" $webpagetxt = "C:\Database\ExternalSources\cftc.txt" $year_cur=get-date -Format yyyy $year_cur_s=get-date -Format yy $year_prev=$year_cur-1 $year_prev_s=$year_cur_s-1 $year_prev2=$year_cur-2 $year_prev2_s=$year_cur_s-2 $searchstring_cur="dea_fut_xls_"+$year_cur+".zip" $searchstring_prev="dea_fut_xls_"+$year_prev+".zip" $searchstring_cur_hist="deafut_xls_1986_"+$year_prev+".zip" $searchstring_prev_hist="deafut_xls_1986_"+$year_prev2+".zip" $cftc=Get-Content $webpagetxt | Select-String -pattern .*$searchstring_cur -Allmatches | % { $_.Matches | % { $_.Value } } if(!$cftc) { $wc.DownloadFile("http://www.cftc.gov/files/dea/history/"+$searchstring_prev,"C:\Database\ExternalSources\cftc.zip") $wc.DownloadFile("http://www.cftc.gov/files/dea/history/"+$searchstring_prev_hist,"C:\Database\ExternalSources\cftc_hist.zip") $newname="\FUT04_"+$year_prev2_s+".xls" } else { $wc.DownloadFile("http://www.cftc.gov/files/dea/history/"+$searchstring_cur,"C:\Database\ExternalSources\cftc.zip") $wc.DownloadFile("http://www.cftc.gov/files/dea/history/"+$searchstring_cur_hist,"C:\Database\ExternalSources\cftc_hist.zip") $newname="\FUT04_"+$year_prev_s+".xls" } $destination="C:\Database\ExternalSources" $source1="C:\Database\ExternalSources\cftc.zip" $source2="C:\Database\ExternalSources\cftc_hist.zip" $shell = new-object -com shell.application New-Item -ItemType Directory -Force -Path $destination -WarningAction SilentlyContinue $shell.namespace($destination).copyhere($shell.namespace("$source1").items()) $zip=$shell.NameSpace($source2) $shell = new-object -com shell.application New-Item -ItemType Directory -Force -Path $destination -WarningAction SilentlyContinue foreach($item in $zip.items()) { $shell.Namespace($destination).copyhere($item) } Rename-Item $destination\annual.xls cftc_current.xls Rename-Item $destination\FUT86_03.xls cftc_early.xls Rename-Item $destination$newname cftc_late.xls & 'C:\Program Files\EViews 8\EViews8_x64.exe' "C:\Database\ext_import_cftc.prg"

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Re: Chicagofed data import into eviews

Postby salahaddin » Fri Dec 12, 2014 9:22 am

Thanks a lot for your help. The problem is I am trying your code in powershel and only last part of the code does not work and eviews gives an error: "C:\DATABASE\EXT_IMPORT_CFTC.PRG" not found on disk.
But all the data is downloaded normally.

I do not have any idea about programming. Could you please help me to download the same thing from chicagofed? I tried to change the website from cftc to chicagofed but now the code does not work at all. Could you please provide help with this specific data?
Thanks again,

regards,
Sam

rousing
Posts: 77
Joined: Fri Jun 11, 2010 5:56 am
Location: Switzerland

Re: Chicagofed data import into eviews

Postby rousing » Fri Dec 12, 2014 10:13 am

The above code is the best help I can provide, but just replace the website to the one of your interest and see if it works, the missing .prg file simply imports the excel data into eviews using the import command

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Re: Chicagofed data import into eviews

Postby salahaddin » Fri Dec 12, 2014 1:24 pm

I changed the website respectively but it did not work. I could manage to write a program which extracts data for only two banks. now the problem is to put those data together for respective banks. I will post my question in a different way.

Still thank you very much for trying to help.

Best wishes,
Sam


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests