The SASEWBGO Interface Engine

Getting Started: SASEWBGO Interface Engine

You can query the World Bank Group Open Data (WDI) database to retrieve the observations or data values for a list of economic time series by specifying the series ID (indicator) of each time series that you want to read into SAS and by specifying a list of the countries for which you want to retrieve the time series.

Before downloading any copyright-protected data series, be aware that you are solely responsible for obtaining copyright permissions for any copyright-protected time series that you download (other than for personal use). To obtain a list of the copyright-protected data series, visit the web page at the following URL:

http://data.worldbank.org/restricted-data

Now that your are informed about the terms of use of the WBGO data, you can access these data, as shown in the following example.

The following statements enable you to access the time series data for gross domestic product per capita in current US dollars for Brazil and China for the seven years starting with 2010 and ending with 2016 (on an annual basis). The observations are sorted by the COUNTRY_ID and the time ID variable DATE. Specify the ISO three-letter or ISO two-letter country code for each country for which you want to retrieve time series, separated by a semicolon. In the following LIBNAME statement, you specify the COUNTRYLIST= option by giving the ISO three-letter code for China as 'chn' and the ISO three-letter code for Brazil as 'bra', separated by a semicolon.



title 'Retrieve Data for GDP per Capita for Brazil and China';
libname wbgo sasewbgo "<physical pathname>"
   OUTXML=gdpgs
   XMLMAP="<physical filename with file extension .map>"
   COUNTRYLIST='chn;bra'
   IDLIST='NY.GDP.PCAP.CD'
   RANGE='2010:2016';

data gdp_gsa;
   set wbgo.gdpgs ;
run;
proc contents data=gdp_gsa; run;
proc print data=gdp_gsa; run;

Figure 54.1: Getting Started with Gross Domestic Product per Capita: gdp_gsa

Retrieve Data for GDP per Capita for Brazil and China

Obscountry_idcountrydateNY.GDP.PCAP.CDtotal_count
1BRBrazil201011121.4214
2BRBrazil201113047.2414
3BRBrazil201212179.6914
4BRBrazil201312106.2114
5BRBrazil201411917.7914
6BRBrazil20158677.7714
7BRBrazil2016.14
8CNChina20104560.5114
9CNChina20115633.8014
10CNChina20126337.8814
11CNChina20137077.7714
12CNChina20147683.5014
13CNChina20158069.2114
14CNChina2016.14


The XML data that the WBGO website returns are placed in a file named by the OUTXML= option—in this case, GDPGS.xml. Note that the XML file extension is excluded from the filename specified in the OUTXML= option. When the SET statement is executed, the XML data are read into a SAS data set named Gdp_gsa.sas7bdat, which resides in the location specified by the string enclosed in double quotation marks in the SASEWBGO LIBNAME statement. So, in the preceding example, assume that you use the following SASEWBGO LIBNAME statement:

libname wbgo sasewbgo "/sasusr/playpens/saskff/wbgo/test/"

Then, the SAS data set is named by the OUTXML= option specification, created by reading the downloaded XML file, and placed in the location

/sasuser/playpens/saskff/wbgo/test/gdpgs.sas7bdat

The XML map that is created is assigned the full pathname specified by the XMLMAP= option. The IDLIST= option specifies the list of time series indicators that you want to retrieve. This option accepts a string, enclosed in single quotation marks, that denotes a list of one or more time series that you select (keep) in the resulting SAS data set. The result, Gdp_gsa, is named in the DATA step and shown in Figure 54.1. The Total_count gives the total number of available observation values in the requested range. Example 54.9 demonstrates how to use multiple SASEWBGO LIBNAME statements to access the entire range of data.

It is more efficient to use the DATA step to store your WBGO data in a SAS data set and then refer to the SAS data set directly in later SAS program steps, but you can also refer to the SASEWBGO SAS library reference (libref) directly, as in the following statements:

proc print data=wbgo.gdpgs; run;

This statement uses the member name, gdpgs, in the PROC PRINT statement; this usage corresponds to specifying the OUTXML=GDPGS option. Although using this statement might seem easier, it is not as efficient, because every time you use the SASEWBGO libref, the SASEWBGO engine reads the entire XML file into SAS. So it is better to refer to the SAS data set repeatedly than to invoke the interface engine repeatedly. See Example 54.1 for sample code that demonstrates how to retrieve multiple time series from one country (China).

Last updated: August 25, 2017