Stata:快速获取世界银行数据-wbopendata

发布时间:2021-11-25 阅读 3079

Stata连享会   主页 || 视频 || 推文 || 知乎 || Bilibili 站

温馨提示: 定期 清理浏览器缓存,可以获得最佳浏览体验。

New! lianxh 命令发布了:
随时搜索推文、Stata 资源。安装:
. ssc install lianxh
详情参见帮助文件 (有惊喜):
. help lianxh
连享会新命令:cnssc, ihelp, rdbalance, gitee, installpkg

课程详情 https://gitee.com/lianxh/Course

课程主页 https://gitee.com/lianxh/Course

⛳ Stata 系列推文:

PDF下载 - 推文合集

作者:李峥 (厦门大学)
邮箱zhengli_u@outlook.com

编者按:本文主要摘译自下文,特此致谢!
Source:WBOPENDATA: Stata module to access World Bank databases -Link-


目录


1. 基本介绍

wbopendata 命令获取的是世界银行的主要发展指标集,这些数据是从官方认可的国际来源汇编而成的。它提供了最新和最准确的全球发展数据。wbopendata 允许 Stata 用户下载超过 17000 个指标,这些指标来源于世界银行的多个数据库,包括但不限于非洲发展指标、营商环境、教育统计、企业调查、全球发展金融、以及性别等。这些指标涵盖了自 1960 年以来超过 256 个国家和地区的信息。

目前支持五种下载选项:

  • 国家:一个国家所有选定年份的 2500 多个指标 (WDI 目录);
  • 专题:一个特定主题内的 WDI 指标,适用于所有选定年份和所有国家 (WDI 目录);
  • 指标:所有选定年份的所有国家的单一指标 (来自任何目录:17000 多个系列);
  • 指标和国家:为一个单一指标选定的国家的所有选定年份 (来自任何目录:17000多个系列);
  • 多指标:为选定的指标选择的所有年份,用分号隔开 (来自 17000 多个系列当中的任何指标)。

该数据库的访问是通过世界银行的开放数据倡议实现的,该倡议提供了对「世界银行数据库 (World Bank databases)」的完全开放访问。

2. 核心参数

国家 country (string):国家和地区的缩写和首字母缩写。如果单独指定,该选项将返回单个国家或地区的所有 WDI 指标 (1076 个系列),这种情况下不允许选择多个国家。如果该选项与一个特定的指标一起选择,则输出的是一个特定国家或地区的系列,或多个国家或地区的系列。当选择多个国家时,请使用三个字母代码,用分号隔开,中间不加空格。

主题 topics (numlist):主题清单,目前支持 21 个主题清单,包括农业和农村发展、援助实效、经济和增长、教育、能源和采矿、环境、金融部门、卫生、基础设施、社会保护和劳工、贫困、私营部门、公共部门、科学和技术、社会发展、城市发展、性别、千年发展目标、气候变化、外债、以及贸易 (单次只能获取单个主题集合)。

指标 indicator (string):指标列表中的指标代码清单。当选择多个指标时,使用分号分隔不同的指标。

3. 应用实例

首先通过以下方式安装 wbopendata 命令:

cnssc install wbopendata, replace

下载单个国家 (例如中国) 的所有 WDI 指标:

. wbopendata, country(chn - China) clear
. tab indicatorcode in 1/10

           Indicator Code |      Freq.     Percent        Cum.
--------------------------+-----------------------------------
        SP.POP.5054.FE.5Y |          1       10.00       10.00
        SP.POP.7579.FE.5Y |          1       10.00       20.00
        SP.REG.BRTH.FE.ZS |          1       10.00       30.00
        ST.INT.RCPT.XP.ZS |          1       10.00       40.00
     TM.TAX.MANF.WM.FN.ZS |          1       10.00       50.00
     TM.TAX.TCOM.WM.FN.ZS |          1       10.00       60.00
        TM.VAL.MRCH.R4.ZS |          1       10.00       70.00
        TX.VAL.FOOD.ZS.UN |          1       10.00       80.00
        TX.VAL.MRCH.RS.ZS |          1       10.00       90.00
           VC.IHR.PSRC.P5 |          1       10.00      100.00
--------------------------+-----------------------------------
                    Total |         10      100.00

下载一个特定主题下面所有的 WDI 指标:

. wbopendata, language(en - English) topics(2 - Aid Effectiveness) clear
. tab indicatorcode in 1/10

   Indicator Code |      Freq.     Percent        Cum.
------------------+-----------------------------------
   SH.DYN.AIDS.ZS |          1       10.00       10.00
      SH.DYN.MORT |          1       10.00       20.00
   SH.STA.ANVC.ZS |          1       10.00       30.00
      SH.STA.MMRT |          1       10.00       40.00
   SH.STA.STNT.ZS |          1       10.00       50.00
      SH.TBS.INCD |          1       10.00       60.00
   SI.DST.FRST.20 |          1       10.00       70.00
      SI.POV.DDAY |          1       10.00       80.00
   SL.EMP.VULN.ZS |          1       10.00       90.00
      SM.POP.NETM |          1       10.00      100.00
------------------+-----------------------------------
            Total |         10      100.00

下载一个指定的指标,例如拖拉机的数量 (ag.agr.trac.no):

. wbopendata, language(en - English) indicator(ag.agr.trac.no) clear

    Metadata for indicator AG.AGR.TRAC.NO
---------------------------------------------------------------------
    Name: Agricultural machinery, tractors
---------------------------------------------------------------------
    Collection: 2 World Development Indicators
---------------------------------------------------------------------
    Description: Agricultural machinery refers to the number of wheel 
    and crawler tractors (excluding garden tractors) in use in
    agriculture at the end of the calendar year specified or during 
    the first quarter of the following year.
---------------------------------------------------------------------
    Note: Food and Agriculture Organization, electronic files and web site.
---------------------------------------------------------------------
    Topic(s): 1 Agriculture and Rural Development
---------------------------------------------------------------------

. tab countryname in 1/10

                           Country Name |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                            Afghanistan |          1       10.00       10.00
            Africa Eastern and Southern |          1       10.00       20.00
             Africa Western and Central |          1       10.00       30.00
                                Albania |          1       10.00       40.00
                                Andorra |          1       10.00       50.00
                                 Angola |          1       10.00       60.00
                             Arab World |          1       10.00       70.00
                              Argentina |          1       10.00       80.00
                                  Aruba |          1       10.00       90.00
                   United Arab Emirates |          1       10.00      100.00
----------------------------------------+-----------------------------------
                                  Total |         10      100.00

以长数据格式下载特定指标,例如获取拖拉机的数量:

. wbopendata, language(en - English) indicator(ag.agr.trac.no) long clear

    Metadata for indicator AG.AGR.TRAC.NO
-------------------------------------------------------------------------
    Name: Agricultural machinery, tractors
-------------------------------------------------------------------------
    Collection: 2 World Development Indicators
-------------------------------------------------------------------------
    Description: Agricultural machinery refers to the number of wheel and 
    crawler tractors (excluding garden tractors) in use in
    agriculture at the end of the calendar year specified or during the 
    first quarter of the following year.
-------------------------------------------------------------------------
    Note: Food and Agriculture Organization, electronic files and web site.
-------------------------------------------------------------------------
    Topic(s): 1 Agriculture and Rural Development
-------------------------------------------------------------------------

. tab year in 1/10

       Year |      Freq.     Percent        Cum.
------------+-----------------------------------
       1960 |          1       10.00       10.00
       1961 |          1       10.00       20.00
       1962 |          1       10.00       30.00
       1963 |          1       10.00       40.00
       1964 |          1       10.00       50.00
       1965 |          1       10.00       60.00
       1966 |          1       10.00       70.00
       1967 |          1       10.00       80.00
       1968 |          1       10.00       90.00
       1969 |          1       10.00      100.00
------------+-----------------------------------
      Total |         10      100.00

下载指定国家的某个指标并以长数据类型进行报告,例如获取 Angola、Burundi、Channel Islands、Denmark 和 Spain 的 6-10 岁女性人口数量的长数据:

. wbopendata, country(ago;bdi;chi;dnk;esp) indicator(sp.pop.0610.fe.un) clear

    Metadata for indicator SP.POP.0610.FE.UN
-----------------------------------------------------------------------------
    Name: Population, ages 6-10, female
-----------------------------------------------------------------------------
    Collection: 12 Education Statistics
-----------------------------------------------------------------------------
    Description: Population, ages 6-10, female is the total number of females age 6-10.
-----------------------------------------------------------------------------
    Note: UNESCO Institute for Statistics (Derived)
-----------------------------------------------------------------------------
    Topic(s): 4 Education
----------------------------------------------------------------------------

. tab countryname

   Country Name |      Freq.     Percent        Cum.
----------------+-----------------------------------
         Angola |          1       20.00       20.00
        Burundi |          1       20.00       40.00
Channel Islands |          1       20.00       60.00
        Denmark |          1       20.00       80.00
          Spain |          1       20.00      100.00
----------------+-----------------------------------
          Total |          5      100.00

获取指定的国家、年份和指标,例如获取 Angola、Burundi、Channel Islands、Denmark 和 Spain 2000 到 2010 年的 6-10 岁女性人口数量的长数据:

. wbopendata, country(ago;bdi;chi;dnk;esp) indicator(sp.pop.0610.fe.un) year(2000:2010) clear  long

    Metadata for indicator SP.POP.0610.FE.UN
-----------------------------------------------------------------------------------
    Name: Population, ages 6-10, female
-----------------------------------------------------------------------------------
    Collection: 12 Education Statistics
-----------------------------------------------------------------------------------
    Description: Population, ages 6-10, female is the total number of females age 6-10.
-----------------------------------------------------------------------------------
    Note: UNESCO Institute for Statistics (Derived)
-----------------------------------------------------------------------------------
    Topic(s): 4 Education
-----------------------------------------------------------------------------------

. tab  year countryname

           |                      Country Name
      Year |    Angola    Burundi  Channel..    Denmark      Spain |     Total
-----------+-------------------------------------------------------+----------
      2000 |         1          1          1          1          1 |         5 
      2001 |         1          1          1          1          1 |         5 
      2002 |         1          1          1          1          1 |         5 
      2003 |         1          1          1          1          1 |         5 
      2004 |         1          1          1          1          1 |         5 
      2005 |         1          1          1          1          1 |         5 
      2006 |         1          1          1          1          1 |         5 
      2007 |         1          1          1          1          1 |         5 
      2008 |         1          1          1          1          1 |         5 
      2009 |         1          1          1          1          1 |         5 
      2010 |         1          1          1          1          1 |         5 
-----------+-------------------------------------------------------+----------
     Total |        11         11         11         11         11 |        55 

. tab  year countryname if sp_pop_0610_fe_un != .

           |                Country Name
      Year |    Angola    Burundi    Denmark      Spain |     Total
-----------+--------------------------------------------+----------
      2000 |         1          1          1          1 |         4 
      2001 |         1          1          1          1 |         4 
      2002 |         1          1          1          1 |         4 
      2003 |         1          1          1          1 |         4 
      2004 |         1          1          1          1 |         4 
      2005 |         1          1          1          1 |         4 
      2006 |         1          1          1          1 |         4 
      2007 |         1          1          1          1 |         4 
      2008 |         1          1          1          1 |         4 
      2009 |         1          1          1          1 |         4 
      2010 |         1          1          1          1 |         4 
-----------+--------------------------------------------+----------
     Total |        11         11         11         11 |        44

利用数据进行地图绘制。作者在他的主页还展示了如何结合 spmap 进行数据的地理可视化。由于地图应当审慎使用,为了避免错误,本文不做展示。

4. 注意事项

用户在使用 wbopendata 时,应首先查看关于每个指标和数据目录的更多详细信息。wbopendata 使用的指标名称和代码与世界银行数据目录中使用的指标名称和代码完全相同,以便于这种交叉参考。

在下载特定系列时,通过指标选项,wbopendata 将默认在 Stata 结果窗口中显示该特定系列的可用数据,包括系列名称、来源、指标的详细描述以及负责编纂该指标的组织等信息。数据目录中所列的世界银行数据集的使用受《世界银行数据使用条款》的约束。

5. 相关推文

Note:产生如下推文列表的 Stata 命令为:
lianxh 数据, m
安装最新版 lianxh 命令:
ssc install lianxh, replace

相关课程

免费公开课

最新课程-直播课

专题 嘉宾 直播/回看视频
最新专题 文本分析、机器学习、效率专题、生存分析等
研究设计 连玉君 我的特斯拉-实证研究设计-幻灯片-
面板模型 连玉君 动态面板模型-幻灯片-
面板模型 连玉君 直击面板数据模型 [免费公开课,2小时]
  • Note: 部分课程的资料,PPT 等可以前往 连享会-直播课 主页查看,下载。

课程主页

课程主页

关于我们

  • Stata连享会 由中山大学连玉君老师团队创办,定期分享实证分析经验。
  • 连享会-主页知乎专栏,700+ 推文,实证分析不再抓狂。直播间 有很多视频课程,可以随时观看。
  • 公众号关键词搜索/回复 功能已经上线。大家可以在公众号左下角点击键盘图标,输入简要关键词,以便快速呈现历史推文,获取工具软件和数据下载。常见关键词:课程, 直播, 视频, 客服, 模型设定, 研究设计, stata, plus, 绘图, 编程, 面板, 论文重现, 可视化, RDD, DID, PSM, 合成控制法

连享会小程序:扫一扫,看推文,看视频……

扫码加入连享会微信群,提问交流更方便

✏ 连享会-常见问题解答:
https://gitee.com/lianxh/Course/wikis

New! lianxhsongbl 命令发布了:
随时搜索连享会推文、Stata 资源,安装命令如下:
. ssc install lianxh
使用详情参见帮助文件 (有惊喜):
. help lianxh