SASEWBGO Interface Engine

The LIBNAME libref SASEWBGO Statement

  • LIBNAME libref SASEWBGO 'physical-name' options;

The LIBNAME statement assigns a SAS library reference (libref) to the physical path of the directory of WBGO data files in which the downloaded WBGO XML data are stored.

You must specify the following arguments:

"physical name"

specifies the location of the folder where your WBGO XML data reside. Enclose the physical name in double quotation marks, and end it with a backslash if the folder is in a Windows environment or a forward slash if it is in a UNIX environment.

COUNTRYLIST='wbgo_countrylist'

specifies the list of country codes, region IDs, or income-level IDs to be included in the output SAS data set. See Table 2 and Table 3 for the IDs available for each aggregation type. This list is semicolon-delimited and must be enclosed in single quotation marks. To list all countries, specify 'all'. Otherwise, you can use the following information to designate the countries listed in the World Bank API. The World Bank uses the ISO three-letter and two-letter codes to represent most of the countries, with the following exceptions:

  • Three-letter code differences: Andorra, Democratic Republic of the Congo, Isle of Man, Romania, Timor-Leste, West Bank and Gaza

  • Two-letter code differences: Democratic Republic of the Congo, Serbia, Timor-Leste, Republic of Yemen, West Bank and Gaza

  • Countries not using ISO codes: Channel Islands, Kosovo

For more information about country codes, visit the web page at the following URL:

http://www.nationsonline.org/oneworld/country_code_list.htm

IDLIST='wbgo_idlist'

specifies the list of time series indicators to be included in the output SAS data set. This list is comma-delimited and must be enclosed in single quotation marks. The crossproduct of the country list and the ID list defines the cross sections of the resulting SAS output data set. For a complete list of available indicators, visit the web page at the following URL:

http://api.worldbank.org/v2/indicators

You can also specify the following options.

AUTOMAP=REPLACE | REUSE

specifies which XMLmap file to use. You can specify the following values:

REPLACE

overwrites the existing XMLmap file and uses the most current XMLmap that is generated by the SASEWBGO engine and specified in the XMLMAP= option.

REUSE

uses a preexisting XMLmap file that is specified in the XMLMAP= option.

CASLIB=wbgo_caslib_name

specifies the name of the CAS library (caslib) where the in-memory CAS table is stored when the XML data from the World Bank Group’s website are read into SAS. The default value is the name of the active caslib. The GOCAS=ON option is required when you specify the CASLIB= option. For an example of using the CASLIB= option, see Example 54.5.

CASOUT=libref.data-table
OUTCAS=libref.data-table

specifies the name of the in-memory CAS table that is created when the XML data from the World Bank Group’s website are read into SAS. The default value is the name that you specify in the OUT= option. The in-memory table is created only when you also specify the GOCAS=ON option. For an example of using the CASOUT= option, see Example 54.5. libref.data-table is a two-level name, where libref refers to the library, and data-table specifies the name of the output data table. For more information about this two-level name, see the section Using CAS Sessions and CAS Engine Librefs.

DEBUG=ON | OFF

specifies whether or not to include diagnostic message logging in the SAS log. This information can be very useful for troubleshooting a problem.

FREQ=M | Q | Y | A

specifies the frequency of the file to be retrieved from the WBGO website. This option is used only in conjunction with the MRV= option. M is monthly, Q is quarterly, and Y (or A) is yearly (annual). By default, FREQ=Y.

GAPFILL=Y | N

specifies whether or not to backfill the unavailable (missing) values in the data retrieved from the WBGO website. This option is used only in conjunction with the MRV= option.

GOCAS=ON | OFF

specifies whether or not to create an in-memory CAS table of the World Bank Group’s Open data (in addition to the SAS data set that is created). When GOCAS=ON, the SASEWBGO engine assumes that there is an active CAS session running before the LIBNAME statement is used. By default, GOCAS=OFF. For an example of using the GOCAS= option, see Example 54.5.

LANGUAGE=EN | ES | FR

specifies the language of the text fields for the retrieved data. The following languages are supported: English (EN), Spanish (ES), and French (FR). The SASEWBGO engine does not support Chinese or Arabic. By default, LANGUAGE=EN.

MAPREF=wbgo_xmlmapfileref

specifies the fileref used for the map assignment. The SASEWBGO engine uses the MAPREF= and XMLMAP= options in the FILENAME statement to assign a file name, as in the following:

FILENAME MyMap "%sysget(WBGO)gstart.map";

You can use the MAPREF= and XMLMAP= options to control where the map resides, what you name the map, and how you refer to it with a fileref. You can use the OUTXML= option to name your XML data file and to name the SAS data set that you created by reading the XML data into SAS. The resulting SAS data set is placed in the folder designated by ‘physical-name’, and you can reference it by using the myLib libref in your SASEWBGO LIBNAME statement. This is shown in Example 54.1, inside the DATA step in the SET statement. In the example, the SET statement reads observations from the input data set myLib.g2start and stores them in a SAS data set named Gdp2chn.

MRV=wbgo_mrv

specifies the number of observations to retrieve relative to the most recent value. You must specify this option when you specify either the GAPFILL= or FREQ= option.

OUTXML=wbgo_xmlfile

specifies the name of both the XML file (downloaded) and the SAS data set created when the XML data are read into SAS. Each WBGO time series that you list in the IDS= option is given a positional numeral: 1 for the first time series ID listed in the ID= option, 2 for the second time series ID listed, and so on. The SASEWBGO engine appends this numeral to the file name of the XML of each data set that the website returns. When all the XML files are retrieved, the data are merged into a SAS data set. When you specify only one WBGO time series ID in the ID= option, the file name has the numeral 1 appended to the OUTXML= file name. By default, OUTXML=WBGO, which creates a file named WBGO1.xml in the current working directory. The SAS data set that is created when the XML data are read into SAS is placed in the folder specified by the physical path in the LIBNAME libref SASEWBGO statement.

PAGE=wbgo_page

specifies the page number of the data to retrieve. Only one page is retrieved for a request, but the page total can be quite large. By default, the first page is retrieved when the page number is not specified. When you want to see more data than what is retrieved for the first page, make another request by specifying the PAGE= option with the number of the page that you want to retrieve. For the page number, you must specify an integer between 1 and the total page count given by the DATA_PAGES variable in the SAS data set named OUTXML1.sas7bdat, which can be viewed in the SAS listing.

PER_PAGE=wbgo_perpage

specifies the number of observations per page of the data to retrieve. The default is 50 observations per page. You can set the per-page number that you want to retrieve by using this option. The per-page count is given by the DATA_PER_PAGE in the SAS data set named OUTXML1.sas7bdat, which can be viewed in the SAS listing. If you want the entire range of data to be downloaded all at once (in one page), you can specify the PER_PAGE= option to be the value of the TOTAL_COUNT that is given in the output SAS data set named by your OUTXML= option. See Example 54.10 for an example of a SAS macro that enables you to download the entire range of data in one page.

RANGE='wbgo_range'

specifies the date range of the data that you want to retrieve in the following formats:

'yyyy:yyyy'

designates the start year and end year for the range of annual time series; for example, RANGE=2000:2001.

'yyyyQn:yyyyQn'

designates the start year and quarter (n) and the end year and quarter (n) for the quarterly time series; for example, RANGE=2009Q1:2010Q3.

'yyyyMnn:yyyyMnn'

designates the start year and month (nn) and the end year and month (nn) for the monthly time series; for example, RANGE=2009M01:2010M08.

For quarterly time series, n is an integer between 1 and 4. For monthly time series, nn is an integer between 1 and 12. Most series in the WDI database are annual. For more information about quarterly and monthly data, consult the World Bank data catalog by visiting the website at the following URL:

http://datacatalog.worldbank.org/

See Example 54.8 for sample code that retrieves Quarterly External Debt Statistics data, and see Example 54.9 for sample code that retrieves monthly Global Economic Monitor commodities data.

SORT=ASC | DESC

specifies the order of the time series observations. You can specify the following values:

ASC

specifies that the dates for the time series observations be in ascending order (within each country’s cross section of data).

DESC

specifies that the dates for the time series observations be in descending order (within each country’s cross section of data).

By default, SORT='ASC'.

URL="wbgo_url_link/<query_type?<query_option=value>><LIMIT=obs_limit>"

queries for useful information, such as listing countries by income level, indicators by source ID, or indicators by topic ID. The SASEWBGO engine stores the information in a temporary utility data set named XWBGOTPU. Specify the following fields in double quotation marks:

wbgo_url_link/

specifies the base WBGO URL that you want to use. The wbgo_url_link in the following example is 'http://api.worldbank.org/v2/'.

    URL="http://api.worldbank.org/v2/topic/5/indicator?format=xml"
query_type?query_option

specifies the type of information that you want to query. You can specify the following query_types and query_options:

countries?incomeLevels=income_level_code

retrieves the names of countries available for a specified income level, such as

     URL="http://api.worldbank.org/v2/countries?incomeLevel=LIC"
source/source_id/indicators?format=xml

retrieves the series indicators available for a specified source ID, such as

     URL="http://api.worldbank.org/v2/source/1/indicators?format=xml"
topic/topic_id/indicator?format=xml

retrieves the series indicators available for a specified topic ID, such as

     URL="http://api.worldbank.org/v2/topic/5/indicator?format=xml"

For a list of available sources, topics, and income levels, see Table 4, Table 5, and Table 2, respectively.

LIMIT=obs_limit

specifies the maximum number of observations to retrieve.

XMLMAP=wbgo_xmlmapfile

specifies the fully qualified name of the location where the XMLmap file is automatically stored. By default, XMLMAP=Wbgo.map.

Last updated: June 19, 2025