Using FRED with Stata

The temptation to form premature theories upon insufficient data is the bane of our profession.

Sherlock Holmes.
The Valley of Fear, Sir Arthur Conan Doyle (1915).

In this blog, I will show you that if is very simple to use FRED data (https://www.wikiwand.com/en/Federal_Reserve_Economic_Data) directly from STATA. As they described in their front page, you will be able to download, graph, and track 793,000 US and international time series from 103 sources. (A) First, you need to create an account on the FRED website (https://fred.stlouisfed.org/):

(B) Then, you have to request an API key into your account (https://research.stlouisfed.org/docs/api/api_key.html):

(C) Once you have received the API key, you can move to STATA (my own API key is not shown):

You can use the following command to set the API key permanently in STATA (only once):

set fredkey key, permanently

Where the key is a series of 32 letters and numbers obtained from FRED in my case (not shown).

(D) From here, you can use the FRED interface:

You can search exchange rate data for France with the FRED interface and select the real effective exchange rate for France coming from the Bank for the International Settlements (https://www.bis.org/statistics/eer.htm):

(D bis) However, when you know the identifier, you can use the following command to import the from FRED and plot the data for the real effective exchange rate of France (an increase indicates a real effective appreciation):

import fred RBFRBIS

rename RBFRBIS reer_france

generate period = tm(1994m1) + _n-1

format %tm period

tsset period, monthly

twoway (tsline reer_france), ytitle("")                          ///
ttitle(Real effective exchange rate - France) tlabel(, grid)     ///
legend(on position(2) ring(0))

You will obtain the following graph:

In four simple steps, you will be able to access, import and visualize data directly from the FRED database.

References

Schenck, D. 2017. Importing data with import fred. The Stata Blog: Not Elsewhere Classified.
https://blog.stata.com/2017/08/08/importing-data-with-import-fred/.

1 Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.