SASEWBGO Interface Engine

Example 54.10 Retrieving the Full Range of Data in One Page

(View the complete code for this example.)

This example demonstrates the use of the PER_PAGE= option inside the SAS macro named X.


options validvarname=any;

title 'Retrieve the Entire Range of Data Observations in One Page';
%macro x(per_page=);

%let i=&per_page;
%if &i<=50 %then %do;
    libname wbgo sasewbgo "%sysget(WBGO)"
       OUTXML=gdpMall
       AUTOMAP=replace
       MAPREF=MyMap
       XMLMAP="%sysget(WBGO)gdpMall.map"
       COUNTRYLIST='all'
       IDLIST='NY.GDP.PCAP.CD,NY.GDP.PCAP.KN,NY.GDP.PCAP.PP.KD'
       RANGE='2010:2016'
       PER_PAGE=&i
       PAGE=1;

   data mygdpMall;
      set wbgo.gdpMall;
   run;

   proc contents data=mygdpMall; run;
   proc print data=mygdpMall; run;

   proc sql noprint;
      select t.total_count into :allnobs
      from work.mygdpMall t;
   quit;

  %if &allnobs>50 %then %do;
    libname wbgo sasewbgo "%sysget(WBGO)"
       OUTXML=gdpTall
       AUTOMAP=replace
       MAPREF=MyMap
       XMLMAP="%sysget(WBGO)gdpTall.map"
       COUNTRYLIST='all'
       IDLIST='NY.GDP.PCAP.CD,NY.GDP.PCAP.KN,NY.GDP.PCAP.PP.KD'
       RANGE='2010:2016'
       PER_PAGE=&allnobs
       PAGE=1;

   data mygdpTall;
      set wbgo.gdpTall;
   run;
  %end;
%end;
%mend;

%x(per_page=50);  /* call the X macro with PER_PAGE=50 */
   proc contents data=mygdpTall; run;
   proc print data=mygdpTall(drop=total_count firstobs=1800 obs=1848); run;

Output 54.10.1: Retrieving Entire Range of Data in One Page for GDP Per Capita for All Countries

Retrieve the Entire Range of Data Observations in One Page

Obs country_id date country NY.GDP.PCAP.CD NY.GDP.PCAP.KN NY.GDP.PCAP.PP.KD
1800 ZF 2010 Sub-Saharan Africa (excluding high income) 1573.79 . 3462.82
1801 ZF 2011 Sub-Saharan Africa (excluding high income) 1728.56 . 3530.07
1802 ZF 2012 Sub-Saharan Africa (excluding high income) 1770.42 . 3602.44
1803 ZF 2013 Sub-Saharan Africa (excluding high income) 1835.66 . 3689.89
1804 ZF 2014 Sub-Saharan Africa (excluding high income) 1854.68 . 3769.24
1805 ZF 2015 Sub-Saharan Africa (excluding high income) 1658.63 . 3786.86
1806 ZF 2016 Sub-Saharan Africa (excluding high income) 1495.05 . 3747.99
1807 ZG 2010 Sub-Saharan Africa 1583.99 . 3483.72
1808 ZG 2011 Sub-Saharan Africa 1740.05 . 3551.43
1809 ZG 2012 Sub-Saharan Africa 1781.70 . 3623.96
1810 ZG 2013 Sub-Saharan Africa 1847.30 . 3711.62
1811 ZG 2014 Sub-Saharan Africa 1866.68 . 3791.25
1812 ZG 2015 Sub-Saharan Africa 1669.50 . 3809.23
1813 ZG 2016 Sub-Saharan Africa 1506.43 . 3770.87
1814 ZJ 2010 Latin America & Caribbean 9076.33 . 15173.42
1815 ZJ 2011 Latin America & Caribbean 10204.63 . 15690.66
1816 ZJ 2012 Latin America & Caribbean 10198.40 . 15930.03
1817 ZJ 2013 Latin America & Caribbean 10337.78 . 16224.98
1818 ZJ 2014 Latin America & Caribbean 10430.58 . 16306.08
1819 ZJ 2015 Latin America & Caribbean 8884.95 . 16257.52
1820 ZJ 2016 Latin America & Caribbean 8589.63 . 16109.77
1821 ZM 2010 Zambia 1489.46 7145.09 3125.53
1822 ZM 2011 Zambia 1672.91 7318.28 3201.29
1823 ZM 2012 Zambia 1763.07 7633.72 3339.28
1824 ZM 2013 Zambia 1878.91 7771.88 3399.71
1825 ZM 2014 Zambia 1763.06 7886.94 3450.05
1826 ZM 2015 Zambia 1337.80 7872.11 3443.56
1827 ZM 2016 Zambia 1280.58 7927.70 3467.88
1828 ZQ 2010 Middle East & North Africa 7172.64 . 15164.00
1829 ZQ 2011 Middle East & North Africa 8327.38 . 15410.28
1830 ZQ 2012 Middle East & North Africa 8897.04 . 15650.08
1831 ZQ 2013 Middle East & North Africa 8655.90 . 15745.31
1832 ZQ 2014 Middle East & North Africa 8541.77 . 15906.86
1833 ZQ 2015 Middle East & North Africa 7383.28 . 16051.44
1834 ZQ 2016 Middle East & North Africa 7277.53 . 16562.00
1835 ZT 2010 IDA & IBRD total 3708.94 . 8072.97
1836 ZT 2011 IDA & IBRD total 4312.90 . 8435.30
1837 ZT 2012 IDA & IBRD total 4530.90 . 8751.88
1838 ZT 2013 IDA & IBRD total 4738.08 . 9082.52
1839 ZT 2014 IDA & IBRD total 4850.22 . 9388.71
1840 ZT 2015 IDA & IBRD total 4540.03 . 9666.18
1841 ZT 2016 IDA & IBRD total 4505.97 . 9986.41
1842 ZW 2010 Zimbabwe 948.33 1011.72 2273.20
1843 ZW 2011 Zimbabwe 1093.65 1137.71 2556.28
1844 ZW 2012 Zimbabwe 1304.97 1304.97 2932.08
1845 ZW 2013 Zimbabwe 1430.00 1307.48 2937.73
1846 ZW 2014 Zimbabwe 1434.90 1315.28 2955.24
1847 ZW 2015 Zimbabwe 1445.07 1316.60 2958.21
1848 ZW 2016 Zimbabwe 1464.58 1306.15 2934.73


Output 54.10.1 shows the results for all countries (ALL) listed in the COUNTRYLIST= option. Three time series are specified in the IDLIST= option. For the entire specified range, for years 2010–2016, the time series have a total of 1,848 observation values.

The X macro shows how to obtain the total observation count by first requesting only 50 observations (PER_PAGE=50, PAGE=1) in the first SASEWBGO LIBNAME statement. The SAS data set that the SASEWBGO engine creates is named GdpMall by the OUTXML= option in the first SASEWBGO LIBNAME statement. The PROC SQL SELECT statement stores the total number of observations from the SAS variable TOTAL_COUNT in the SAS macro variable named ALLNOBS. This allows the second SASEWBGO LIBNAME statement to use the total observation count in the PER_PAGE= option so that all 1,848 observations are downloaded in one page. The SAS data set gdpTall contains all 1,848 observations. For brevity, only the last 48 observations are shown in Output 54.10.1.

Last updated: June 19, 2025