SASEWBGO Interface Engine

Example 54.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 54.4.1: Using the SORT= Option

Using the SORT= Option

Obs country_id date country NY.GDP.PCAP.CD NY.GDP.PCAP.KN NY.GDP.PCAP.PP.KD
1 BR 2016 Brazil 8710.10 19291.34 14446.41
2 BR 2015 Brazil 8814.00 20109.69 15059.23
3 BR 2014 Brazil 12112.59 21024.57 15744.35
4 BR 2013 Brazil 12300.32 21098.94 15800.04
5 BR 2012 Brazil 12370.02 20663.17 15473.71
6 BR 2011 Brazil 13245.61 20455.64 15318.31
7 BR 2010 Brazil 11286.24 19854.76 14868.33
8 CN 2016 China 8147.94 53387.62 13487.82
9 CN 2015 China 8066.94 50236.89 12691.82
10 CN 2014 China 7678.60 47171.32 11917.34
11 CN 2013 China 7050.65 44133.51 11149.87
12 CN 2012 China 6316.92 41155.72 10397.56
13 CN 2011 China 5618.13 38341.65 9686.62
14 CN 2010 China 4550.45 35167.06 8884.59


Output 54.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: June 19, 2025