Stata 15 help for import fred

[D] import fred -- Import data from Federal Reserve Economic Data

Syntax

Set FRED key

set fredkey key [, permanently]

Import FRED data

import fred series_list [, options]

or

import fred, serieslist(filename) [options]

Describe series

freddescribe series_list [, detail realtime(start end)]

Search series

fredsearch keyword_list [, search_options]

key is a valid API key, which is provided by the St. Louis Federal Reserve and may be obtained from https://research.stlouisfed.org/docs/api/api_key.html.

series_list is a list of FRED codes, for example, FEDFUNDS.

keyword_list is a list of keywords.

options Description ------------------------------------------------------------------------- * serieslist(filename) specify series IDs using a file daterange(start end) restrict to only observations within specified date range aggregate(frequency [, method]) specify the aggregation level and aggregation type realtime(start end) import historical vintages between specified dates vintage(datespec) import historical data by vintage dates nrobs import only new and revised observations initial import only first value for each observation in a series long import data in long format nosummary suppress summary table

clear clear data in memory before importing FRED series ------------------------------------------------------------------------- * serieslist() is required if series_list is not specified. clear does not appear in the dialog box.

If start and end are provided as dates, they must be daily dates using notation of the form 31Jan2016, 2016-01-31, 2016/01/31, or 01/31/2016.

datespec may be

date a daily date date_1 date_2 ... date_n a list of daily dates _all all available dates

search_options Description ------------------------------------------------------------------------- idonly require keywords to appear in series IDs only tags(tag_list) search by tag_list taglist list tags present in current search results sort(sortby[, sortorder]) list matched series in order specified by sortby detail list full metainformation for each search result

saving(filename [, replace]) save series information to filename.dta ------------------------------------------------------------------------- saving() does not appear in the dialog box.

Menu

File > Import > Federal Reserve Economic Data (FRED)

For information and examples on using the FRED interface, see The FRED interface in [D] import fred.

Description

import fred imports data from the Federal Reserve Economic Data (FRED) into Stata. import fred supports data on FRED as well as historical vintage data on Archival FRED (ALFRED). freddescribe and fredsearch provide tools to describe series in the database and to search FRED for data based on keywords and tags.

Options

Options are presented under the following headings:

Option for set fredkey Options for import fred Options for freddescribe Options for fredsearch

Option for set fredkey

permanently specifies that, in addition to setting the key for the current Stata session, the key be remembered and become the default key when you invoke Stata.

Options for import fred

serieslist(filename) allows you to import the series specified in filename. The series file must contain a variable called seriesid that contains the IDs of the series you wish to import. serieslist() is required if series_list is not specified.

daterange(start end) specifies that only observations between the start date and end date should be imported. start and end must be specified as either a daily date or a missing value (.). Use daterange(. end) to import all observations from the first available through end. Use daterange(start .) to import from start through the most recently available date.

aggregate(frequency[, method) specifies that the data should be imported at a lower frequency than the series' native frequency along with an optional method of aggregation.

frequency may be daily, weekly, biweekly, monthly, quarterly, semiannual, annual, weekly ending friday, weekly ending thursday, weekly ending wednesday, weekly ending tuesday, weekly ending monday, weekly ending sunday, weekly ending saturday, biweekly ending wednesday, or biweekly ending monday.

method may be avg (the within-period average), sum (the within-period sum), or eop (the end-of-period value). The default is avg.

realtime(start end) specifies a real-time period between which all vintages for each series are imported. The vintage available on start is imported, as are all vintages released between start and end. Either of start or end may be replaced by a missing value (.). If start is a missing value, then all vintages from the first available up through end are imported. If end is a missing value, then all vintages from start up through the most recent available are imported. realtime() may not be combined with vintage().

vintage(datespec) imports historical vintage data according to datespec. datespec may either be a list of daily dates or _all. When datespec is a list of dates, the specified series are imported as they were available on the dates in datespec. When datespec is _all, all vintages of the specified series are imported. vintage() may not be combined with realtime().

nrobs specifies that only observations that are new or revised in each vintage be imported. Old and unrevised observations are imported as the missing value .u.

initial specifies that only the first value for each observation of the series be imported. This option may not be combined with nrobs.

long specifies that each series be imported in long format.

nosummary suppresses the summary table.

The following option is available with import fred but is not shown in the dialog box:

clear specifies that the data in memory should be replaced with the imported FRED data.

Options for freddescribe

detail displays full metainformation available about series_list.

realtime(start end) provides historical vintage information about series_list during the real-time period specified by start and end. Either start or end may be replaced by a missing value (.). If start is a missing value, then all vintages from the first available up through end are described. If end is a missing value, then all vintages from start up through the most recent available are described.

Options for fredsearch

idonly specifies that the keywords in keyword_list be found in series IDs rather than elsewhere in the metadata.

tags(tag_list) searches for series that have all the tags specified in tag_list. The complete list of available tags is provided by FRED. Tags form a space-separated list. Tags are case-sensitive and all FRED tags are in lowercase.

taglist lists all the tags present in the current search results.

sort(sortby[, sortorder]) lists the search results in the order specified by sortby.

When searching series, sortby may be popularity, id, title, lastupdated, frequency, obsstart, obsend, units, or seasonaladj. By default, popularity is used.

When searching with the taglist option, sortby may be name or series_count. name means the tag name, and series_count is the count of series associated with the tag in the search results. By default, series_count is used.

You can optionally change the order of the search results from descending (descending) to ascending (ascending) order. The default order when searching by popularity, lastupdated, or series_count is descending; otherwise, the default sort order is ascending.

detail lists full metainformation for each series that appears in the search results.

The following option is available with fredsearch but is not shown in the dialog box:

saving(filename[, replace) saves the search results to a file. The filename may then be specified in the serieslist() option of import fred to import the series located by the search. The optional replace specifies that filename be overwritten if it exists.

Examples

Whether you plan to use the FRED interface or the import fred command, you must first have a valid API key. API keys are provided by the St. Louis Federal Reserve and may be obtained from https://research.stlouisfed.org/docs/api/api_key.html. The key will be a 32-character alphanumeric string. You will be prompted to enter this key the first time you open the FRED interface. Alternatively, you can type

. set fredkey key, permanently

where key is your API key.

Find monthly data on the exchange rate between the U.S. dollar and the Japanese Yen . fredsearch us dollar yen exchange rate monthly

Import the series for the answer from the results produced above . import fred EXJPUS

Stored results

fredsearch stores the following in r():

Scalars r(series_ids) list of series IDs contained in the search results


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index