Tải dữ liệu kinh tế từ WB, IMF, OECD trên Stata
Tải và cập nhật dữ liệu tự động trên Stata với sdmxuse
Thực hành tải dữ liệu kinh tế với sdmxuse
Một ví dụ khác về cách sử dụng sdmxuse giúp bạn thành thạo hơn trong việc truy xuất các dữ liệu mong muốn từ WB, IMF…
Bước 1: Chọn nguồn dữ liệu
Tìm các bộ dữ liệu sẵn có từ OECD với sdmxuse dataflow
. sdmxuse dataflow OECD, clear
Giới hạn các bộ dữ liệu gần nhất, tháng 12/2020
. list if regexm(dataflow_description, "December 2020"), noobs +-----------------------------------------------------------+ | dataflow_id dataflow_description | |-----------------------------------------------------------| | EO Economic Outlook No 108 - December 2020. | | EO108_INTERNET Economic Outlook No 108 - December 2020. | +-----------------------------------------------------------+
Bước 2: Xác định cấu trúc dữ liệu
Tìm hiểu định nghĩa cấu trúc bộ dữ liệu EO với sdmxuse datastructure
. sdmxuse datastructure OECD, clear dataset(EO) Order of dimensions: (LOCATION.VARIABLE.FREQUENCY)
Dữ liệu có 3 chiều với thứ tự các chiều là: LOCATION.VARIABLE.FREQUENCY
Bước 3: Tùy chỉnh dữ liệu cần thu thập
Thực hiện các truy vấn và hiển thị với sdmxuse data
Lấy dữ liệu tăng trưởng GDP (GDPV_ANNPCT) tần suất năm của Pháp (FRA) và DEU (Đức) bắt đầu từ năm 1993
. sdmxuse data OECD, clear dataset(EO) dimensions(FRA+DEU.GDPV_ANNPCT.A) start(1993) 2 serie(s) imported . list in 1/10 +-------------------------------------------------------+ | location variable freque~y time value | |-------------------------------------------------------| 1. | FRA GDPV_ANNPCT A 1993 -.60371474 | 2. | DEU GDPV_ANNPCT A 1993 -.9914811 | 3. | FRA GDPV_ANNPCT A 1994 2.3364449 | 4. | FRA GDPV_ANNPCT A 1995 2.2234781 | 5. | FRA GDPV_ANNPCT A 1996 1.3934389 | |-------------------------------------------------------| 6. | FRA GDPV_ANNPCT A 1997 2.3102397 | 7. | FRA GDPV_ANNPCT A 1998 3.6157369 | 8. | FRA GDPV_ANNPCT A 1999 3.2973126 | 9. | FRA GDPV_ANNPCT A 2000 4.0874389 | 10. | FRA GDPV_ANNPCT A 2001 1.9999047 | +-------------------------------------------------------+ . list in -10/l +-------------------------------------------------------+ | location variable freque~y time value | |-------------------------------------------------------| 51. | DEU GDPV_ANNPCT A 2013 .55201994 | 52. | DEU GDPV_ANNPCT A 2014 2.2062946 | 53. | DEU GDPV_ANNPCT A 2015 1.2363999 | 54. | DEU GDPV_ANNPCT A 2016 2.1422945 | 55. | DEU GDPV_ANNPCT A 2017 2.9083906 | |-------------------------------------------------------| 56. | DEU GDPV_ANNPCT A 2018 1.2952366 | 57. | DEU GDPV_ANNPCT A 2019 .58996876 | 58. | DEU GDPV_ANNPCT A 2020 -5.5323572 | 59. | DEU GDPV_ANNPCT A 2021 2.798972 | 60. | DEU GDPV_ANNPCT A 2022 3.3074157 | +-------------------------------------------------------+
Biến đổi dữ liệu thành dạng chuỗi ứng với mỗi quốc gia
. sdmxuse data OECD, clear dataset(EO) dimensions(FRA+DEU.GDPV_ANNPCT.A) start(1993) timeseries 2 serie(s) imported . list in 1/10 +--------------------------------+ | time deu fra | |--------------------------------| 1. | 1993 -.9914811 -.60371474 | 2. | 1994 2.4695184 2.3364449 | 3. | 1995 1.6111197 2.2234781 | 4. | 1996 .85127984 1.3934389 | 5. | 1997 1.8621003 2.3102397 | |--------------------------------| 6. | 1998 1.7932781 3.6157369 | 7. | 1999 1.7461211 3.2973126 | 8. | 2000 3.1423351 4.0874389 | 9. | 2001 1.8148896 1.9999047 | 10. | 2002 -.16866006 1.0967651 | +--------------------------------+
Truy xuất dữ liệu tăng trưởng GDP tần suất năm cho tất cả các quốc gia và tổng hợp thành dạng bảng
. sdmxuse data OECD, clear dataset(EO) dimensions(.GDPV_ANNPCT+CPIH.A) panel(location) 73 serie(s) imported . list in 1/10 +-------------------------------------+ | location time cpih gdpv_ann~t | |-------------------------------------| 1. | ARG 1994 . 5.8294649 | 2. | ARG 1995 . -2.8452097 | 3. | ARG 1996 . 5.5266901 | 4. | ARG 1997 . 8.1110462 | 5. | ARG 1998 . 3.8501798 | |-------------------------------------| 6. | ARG 1999 . -3.3854578 | 7. | ARG 2000 . -.78899856 | 8. | ARG 2001 . -4.40884 | 9. | ARG 2002 . -10.894485 | 10. | ARG 2003 . 8.9553637 | +-------------------------------------+ . list in -10/l +-------------------------------------+ | location time cpih gdpv_ann~t | |-------------------------------------| 2379. | ZAF 2013 . 2.4852069 | 2380. | ZAF 2014 . 1.8469861 | 2381. | ZAF 2015 . 1.1937366 | 2382. | ZAF 2016 . .39905564 | 2383. | ZAF 2017 . 1.4145807 | |-------------------------------------| 2384. | ZAF 2018 . .78702113 | 2385. | ZAF 2019 . .15257815 | 2386. | ZAF 2020 . -8.1292461 | 2387. | ZAF 2021 . 3.0910134 | 2388. | ZAF 2022 . 2.533818 | +-------------------------------------+
Bổ sung thêm thông tin mô tả các chiều của bộ dữ liệu vào dữ liệu tổng hợp
. sdmxuse data OECD, clear dataset(EO) dimensions(.GDPV_ANNPCT.A) mergedsd 54 serie(s) imported . list in 1/10 +---------------------------------------------------------------------------------------------------+ 1. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2004 | 8.9111692 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 2. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 1998 | 3.8501798 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 3. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2000 | -.78899856 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 4. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2013 | 2.4053238 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 5. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2003 | 8.9553637 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 6. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 1995 | -2.8452097 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 7. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2001 | -4.40884 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 8. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2014 | -2.5126153 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 9. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2011 | 6.0039517 | +---------------------------------------------------------------------------------------------------+ +---------------------------------------------------------------------------------------------------+ 10. | location | locatio~l | variable | variable_lbl | freque~y | freque~l | | ARG | Argentina | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |---------------------------------------------------------------------------------------------------| | time | value | | 2015 | 2.7311598 | +---------------------------------------------------------------------------------------------------+ . list in -10/l +------------------------------------------------------------------------------------------------------+ 2378. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 1990 | -.31775827 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2379. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 2004 | 4.5545427 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2380. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 1998 | .51736871 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2381. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 1977 | -.09398891 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2382. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 2014 | 1.8469861 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2383. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 2019 | .15257815 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2384. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 2003 | 2.9490742 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2385. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 2002 | 3.6678287 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2386. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 1992 | -2.1370344 | +------------------------------------------------------------------------------------------------------+ +------------------------------------------------------------------------------------------------------+ 2387. | location | location_lbl | variable | variable_lbl | freque~y | freque~l | | ZAF | South Africa | GDPV_ANNPCT | Gross domestic product, volume, growth | A | Annual | |------------------------------------------------------------------------------------------------------| | time | value | | 1978 | 3.0144871 | +------------------------------------------------------------------------------------------------------+
Tài liệu Tham khảo
- http://consosukien.vn/xu-huong-trao-doi-thong-tin-cua-thong-ke-hien-dai.htm
SDMX. 2017. Learning about SDMX basics. https://sdmx.org/?page id=2555. - Fontenay S. sdmxuse: Command to Import Data from Statistical Agencies using the SDMX Standard. The Stata Journal. 2018;18(4):863-870. doi:10.1177/1536867X1801800407