get_cpiu

Data retrieval

Load CPI-U or R-CPI-U-RS price index data series into memory or a matrix.

Description

get_cpiu retrieves annual average CPI-U (the default) or R-CPI-U-RS (formerly CPI-U-RS) data series from the Bureau of Labor Statistics. The series may be loaded as a variable joined to existing data in memory, as a matrix, or as a new dataset replacing data in memory.

Users may request inflation adjustment factors based on the retrieved price index be generated. Inflation adjustment factors are used to convert current (nominal) dollars into constant (real) dollars. The base_year() option specifies which year to use as the base year for the inflation adjustment factor. For example, get_cpiu, base_year(2022) clear will load into memory the CPI-U data series as variable cpiu and generate cpiu_2022_adj. Users may then multiply a variable containing nominal dollar values by cpiu_2022_adj to obtain the values in 2022 constant dollars.

Data series are automatically cached. Users can load the cached data rather than re-downloading it by specifying use_cache. Note that price indices are occasionally back-revised. When loading cached data, get_cpiu will display the date when the was originally downloaded. To refresh the cached data with the latest available data, run get_cpiu without the use_cache option.

Syntax

get_cpiu, { merge | matrix(matname) | clear } [options]
Option Description
merge Merge the data into the dataset in memory.
matrix(matname) Load data into matrix matname.
clear Load the data into memory, replacing the dataset currently in memory. Cannot be combined with merge.
rs Retrieve the R-CPI-U-RS. If unspecified, the CPI-U will be retrieved.
base_year(integer) Create inflation-adjustment factors from nominal dollars to real dollars, using the specified base year.
yearvar(varname) If merge is specified, the key variable on which to merge the data into the dataset in memory. Default is yearvar(year).
nolabel Do not attach variable labels to the retrieved data. May only be specified with merge or clear.
use_cache Use data from the cache if it exists. An internet connection is required to retrieve data when use_cache is not specified or cached data does not exist.
user_agent(string) Email address to provide in the header of the HTTP request to the BLS website; passed to copy_curl.

Examples

Merge the CPI-U into the dataset in memory.

get_cpiu, merge

Load CPI-U-RS and inflation-adjustment factors to 2022 constant dollars into memory, replacing the dataset currently in memory.

get_cpiu, rs base_year(2022) clear

Load cached CPI-U data series into matrix inflation.

get_cpiu, matrix(inflation) use_cache