View on GitHub

dbnomics

Stata client for DB.nomics, the world's economic database

dbnomics

Stata client for DB.nomics, the world’s economic database (https://db.nomics.world)

Description

dbnomics provides a suite of tools to search, browse and import time series data from DB.nomics, the world’s economic database (https://db.nomics.world). DB.nomics is a web-based platform that aggregates and maintains time series data from various statistical agencies across the world. dbnomics only works with Stata 14.0 or higher.

dbnomics provides an interface between Stata and DB.nomics’ API (https://api.db.nomics.world/apidocs). It enables creating custom queries through Stata’s options syntax (see Examples). To achieve this, the command relies on Erik Lindsley’s libjson Mata library (ssc install libjson).

Installation

net install dbnomics, from("https://dbnomics-stata.github.io/dbnomics")

Syntax

. //Load list of providers
. dbnomics providers [, clear insecure]

. //Load content tree for a given provider
. dbnomics tree , provider(PRcode) [clear insecure]

. //Load dataset structure given a provider and dataset
. dbnomics datastructure , provider(PRcode) dataset(DScode) [clear insecure]

. // Load list of series for a given provider and dataset
. dbnomics series , provider(PRcode) dataset(DScode) [dimensions_opt|sdmx(SDMX_mask)] [clear insecure limit(int) offset(int)]

. // Import series for a given provider and dataset
. dbnomics import , provider(PRcode) dataset(DScode) [dimensions_opt|sdmx(SDMX_mask)|seriesids(SERIES_list)] [clear insecure limit(int) offset(int)]

. // Load a single series
. dbnomics use series_id , provider(PRcode) dataset(DScode) [clear insecure]

. // Search for data across DB.nomics' providers
. dbnomics find search_str [, clear insecure limit(int) offset(int)]

. // Load and display recently updated datasets
. dbnomics news [, clear insecure limit(int) offset(int)]

Options

Main

series

Note: dimensions_opt(dim_values) and sdmx(SDMX_mask) are mutually exclusive.

import

Note: dimensions_opt(dim_values), sdmx(SDMX_mask) and seriesids(SERIES_list) are mutually exclusive.

use

find/news

Remarks

dbnomics has two main dependencies:

  1. The Mata json library libjson by Erik Lindsley, needed to parse JSON strings. It can be found on SSC: ssc install libjson.
  2. The routine moss by Robert Picard & Nicholas J. Cox, needed to clean unicode sequences. It can be found on SSC: ssc install moss.

After each API call, dbnomics stores significant metadata in the form of dataset characteristics. Type char li _dta[] after dbnomics to obtain important info about the data, e.g., the API endpoint.

Examples

. // Search for producer price data on DB.nomics' platform:
. dbnomics find "producer price", clear
(output omitted)

. // Load the list of available providers with additional metadata:
. dbnomics providers, clear
Fetching providers list
(63 providers read)

. // Show recently updated datasets:
. dbnomics news, clear
(output omitted)

. // Load the dataset tree of of the AMECO provider:
. dbnomics tree, provider(AMECO) clear

. // Analyse the structure of dataset PIGOT for provider AMECO:
. dbnomics datastructure, provider(AMECO) dataset(PIGOT) clear
Price deflator gross fixed capital formation: other investment
82 series found. Order of dimensions: (freq.unit.geo)

. // List all series in AMECO/PIGOT containing deflators in national currency:
. dbnomics series, provider(AMECO) dataset(PIGOT) unit(national-currency-2015-100) clear
39 of 82 series selected. Order of dimensions: (freq.unit.geo)

. // Import all series in AMECO/PIGOT containing deflators in national currency:
. dbnomics import, provider(AMECO) dataset(PIGOT) unit(national-currency-2015-100) clear
Processing 39 series
........................................
39 series found and imported

. // Import a few AMECO/PIGOT series:
. dbnomics import, pr(AMECO) d(PIGOT) seriesids(ESP.3.1.0.0.PIGOT,SVN.3.1.0.0.PIGOT,LVA.3.1.99.0.PIGOT) clear
Processing 3 series
...
3 series found and imported

. // Import one specific series from AMECO/PIGOT:
. dbnomics use ESP.3.1.0.0.PIGOT, pr(AMECO) d(PIGOT) clear
Annually – (National currency: 2015 = 100) – Spain (AMECO/PIGOT/ESP.3.1.0.0.PIGOT)
(62 observations read)

. // Eurostat supports SMDX queries. Import all series in Eurostat/ei_bsin_q_r2 related to Belgium:
. dbnomics import, provider(Eurostat) dataset(ei_bsin_q_r2) geo(BE) s_adj(NSA) clear
Processing 14 series
..............
14 series found and imported

. // Do the same using sdmx:
. dbnomics import, provider(Eurostat) dataset(ei_bsin_q_r2) sdmx(Q..NSA.BE) clear
Processing 14 series
..............
14 series found and imported

. // The Eurostat/urb_ctran dataset offers 12280 series, more than permitted at once by DB.nomics:
. dbnomics series, provider(Eurostat) dataset(urb_ctran) clear
Warning: series set larger than dbnomics maximum provided items.
Use the offset option to load series beyond the 1000th one.
12280 series selected. Order of dimensions: (FREQ.indic_ur.cities). Only #1 to #1000 retrieved

. // Using limit and offset, we can instruct dbnomics to only get series #1001 to #1100:
. dbnomics import, provider(Eurostat) dataset(urb_ctran) limit(100) offset(1000) clear
Processing 100 series
..................................................    50
..................................................   100
12280 series found and #1001 to #1100 loaded

Bugs?

Write at: signoresimone at yahoo [dot] it