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;
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 |
Obs | country_id | date | country | NY.GDP.PCAP.CD | NY.GDP.PCAP.KN | NY.GDP.PCAP.PP.KD |
---|---|---|---|---|---|---|
1 | BR | 2016 | Brazil | . | . | . |
2 | BR | 2015 | Brazil | 8677.77 | 8743.15 | 14532.98 |
3 | BR | 2014 | Brazil | 11917.79 | 9163.63 | 15231.91 |
4 | BR | 2013 | Brazil | 12106.21 | 9198.86 | 15290.46 |
5 | BR | 2012 | Brazil | 12179.69 | 9012.48 | 14980.66 |
6 | BR | 2011 | Brazil | 13047.24 | 8925.68 | 14836.38 |
7 | BR | 2010 | Brazil | 11121.42 | 8666.76 | 14406.01 |
8 | CN | 2016 | China | . | . | . |
9 | CN | 2015 | China | 8069.21 | 43991.55 | 13572.19 |
10 | CN | 2014 | China | 7683.50 | 41354.61 | 12758.65 |
11 | CN | 2013 | China | 7077.77 | 38737.58 | 11951.25 |
12 | CN | 2012 | China | 6337.88 | 36126.73 | 11145.75 |
13 | CN | 2011 | China | 5633.80 | 33658.85 | 10384.37 |
14 | CN | 2010 | China | 4560.51 | 30876.04 | 9525.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).