Using FRED with Stata

Jamel Saadaoui
The Stata Gallery
Published in
3 min readFeb 29, 2024

--

In this blog, I will show you that if it is simple to use FRED data directly from STATA. The Federal Reserve Economic Data (FRED) is a database maintained by the Research division of the Federal Reserve Bank of St. Louis. As they described in their front page, you will be able to download, graph, and track 823,000 US and international time series from 114 sources.

Step number 1: First, you need to create an account on the FRED website: https://fred.stlouisfed.org/

Step number 2: Then, you have to request an API key into your account:

Step number 3: 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).

Step number 4: 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):

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

**#************ Import from FRED *******************************

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))

**#*** The end of program **************************************

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

References

About the author

I am a teacher and researcher in social sciences, specialized in several topics related to international economics. Sometimes, I write on Probability, Philosophy, Economics, and other topics with a macro perspective. My recent works explore the interactions between geopolitical tensions and the economy. More information on my personal website: https://www.jamelsaadaoui.com/

--

--

Jamel Saadaoui
The Stata Gallery

I am a teacher and researcher in International Economics. Sometimes, I write on Probability, Philosophy, Economics, and other topics with a macro perspective.