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 it is very simple to use FRED data (about) 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 (source):

(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

4 Comments

Leave a Reply to Using DBnomics with Stata – EconMacro Cancel reply

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