Request data from Haver Analytics database
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve all historical data for the Haver
Analytics variable 'FFED'
. The descriptor for
this variable is Federal Funds [Effective] Rate (% p.a.).
variable = 'FFED'; % return data for FFED d = fetch(c,variable);
Display the first three rows of data.
d(1:3,:)
ans = 715511.00 2.38 715512.00 2.50 715515.00 2.50
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve historical data from January 1, 2005 through December 31,
2005 for 'FFED'
.
variable = 'FFED'; % return data for FFED startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate);
Display the first three rows of data.
d(1:3,:)
ans = 732315.00 2.25 732316.00 2.25 732317.00 2.25
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Retrieve the information of the Haver
Analytics variable 'FFED'
. The descriptor for
this variable is Federal Funds [Effective] Rate (% p.a.).
variable = 'FFED';
x = info(c,variable);
info
returns the structure x
containing fields describing the Haver
Analytics variable.
Retrieve quarterly data. When you specify a date that is outside the
date range in the variable, you might experience unexpected results.
To prevent this, use the EndDate
field for the end
of the date range.
startdate = '06/01/2000'; % start of date range enddate = x.EndDate; % end of date range period = 'q'; % quarterly data d = fetch(c,variable,startdate,enddate,period)
Display the first three rows of data.
d(1:3,:)
ans = 730759.00 6.52 730851.00 6.50 730941.00 5.61
d
contains the numeric representation of the date
in the first column and the closing value in the second column.
Close the Haver Analytics connection.
close(c)
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Adjust the display format for currency.
format bank
Set the data return format to table using the
DataReturnFormat
property of the
haver
object.
c.DataReturnFormat = 'table';
Retrieve historical data from January 1, 2005 through December 31,
2005 for 'ABQ'
and display the results.
ABQ
provides bankruptcy filings in the
US.
variable = 'ABQ'; % return data for ABQ startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate)
ans = 4×2 table Time TotalBankruptcyFilings_U_S__Units_ _________ __________________________________ 732402.00 401149.00 732493.00 467333.00 732585.00 542002.00 732677.00 667431.00
d
is a table with the date in the first variable
and the bankruptcy amount in the second variable. The date is an array
of MATLAB® date numbers.
Close the Haver Analytics connection.
close(c)
Connect to the Haver Analytics database.
c = haver('c:\work\haver\usecon.dat');
Adjust the display format for currency.
format bank
Set the data return format to table using the
DataReturnFormat
property of the
haver
object. Also, set the date and time return
format to a datetime
array using the
DatetimeType
property.
c.DataReturnFormat = 'table'; c.DatetimeType = 'datetime';
Retrieve historical data from January 1, 2005 through December 31,
2005 for 'ABQ'
and display the results.
ABQ
provides bankruptcy filings in the
US.
variable = 'ABQ'; % return data for ABQ startdate = '01/01/2005'; % start of date range enddate = '12/31/2005'; % end of date range d = fetch(c,variable,startdate,enddate)
ans = 4×2 table Time TotalBankruptcyFilings_U_S__Units_ ____________________ __________________________________ 31-Mar-2005 00:00:00 401149.00 30-Jun-2005 00:00:00 467333.00 30-Sep-2005 00:00:00 542002.00 31-Dec-2005 00:00:00 667431.00
d
is a table with the date and time in the first
variable and the bankruptcy amount in the second variable. The first
variable is a datetime
array.
Close the Haver Analytics connection.
close(c)
c
— Haver Analytics connectionHaver
Analytics connection, specified as a connection object created
using haver
.
variable
— Haver Analytics variableHaver Analytics variable, specified as a character vector or string scalar to denote which historical data to retrieve.
Example: 'FFED'
Data Types: char
| string
startdate
— Start dateStart date, specified as a character vector, string scalar, or MATLAB date number that denotes the beginning of the date range to retrieve data.
Data Types: double
| char
| string
enddate
— End dateEnd date, specified as a character vector, string scalar, or MATLAB date number that denotes the end of the date range to retrieve data.
Data Types: double
| char
| string
period
— Period'd'
| 'w'
| 'm'
| 'q'
| 'a'
Period, specified as one of these values that denotes the time period for the historical data:
'd'
for daily values
'w'
for weekly values
'm'
for monthly values
'q'
for quarterly values
'a'
for annual values
d
— Historical dataHistorical data, returned as a matrix with the numeric representation of the date in the first column and the value in the second column.