The SASEWBGO Interface Engine

Example 55.4 Sorting Time Series in Descending Order Using the Sort= Option

(View the complete code for this example.)

This example shows how to retrieve data that are sorted in descending order (within each country’s BY group).

options validvarname=any;

title 'Using the SORT= Option';
libname wbgo sasewbgo "%sysget(WBGO)"
   OUTXML=gdpdes
   AUTOMAP=replace
   MAPREF=MyMap
   XMLMAP="%sysget(WBGO)gdpdes.map"
   COUNTRYLIST='chn;bra'
   IDLIST='NY.GDP.PCAP.CD,NY.GDP.PCAP.KN,NY.GDP.PCAP.PP.KD'
   RANGE='2010:2016'
   PER_PAGE=25
   SORT=desc
   ;

data mygdpdesc;
     set wbgo.gdpdes;
run;
proc contents data=mygdpdesc; run;
proc print data=mygdpdesc(drop=total_count); run;

Output 55.4.1: Using the SORT= Option

Using the SORT= Option

Obscountry_iddatecountryNY.GDP.PCAP.CDNY.GDP.PCAP.KNNY.GDP.PCAP.PP.KD
1BR2016Brazil...
2BR2015Brazil8677.778743.1514532.98
3BR2014Brazil11917.799163.6315231.91
4BR2013Brazil12106.219198.8615290.46
5BR2012Brazil12179.699012.4814980.66
6BR2011Brazil13047.248925.6814836.38
7BR2010Brazil11121.428666.7614406.01
8CN2016China...
9CN2015China8069.2143991.5513572.19
10CN2014China7683.5041354.6112758.65
11CN2013China7077.7738737.5811951.25
12CN2012China6337.8836126.7311145.75
13CN2011China5633.8033658.8510384.37
14CN2010China4560.5130876.049525.82


Output 55.4.1 shows the results of using the SORT= option to sort each country’s observations in descending order (most recent observation first). There are only 25 observations because the PER_PAGE=25 option is specified, and the default page is the first page of observations. The SASEWBGO engine defaults to SORT=ASC (ascending dates) within each BY group (country).

Last updated: August 11, 2020