The SASERAIN Interface Engine

Example 54.6 Retrieving Historical Weather Data for Two Cities for a Date Range

(View the complete code for this example.)

This example shows how to retrieve past weather data for two locations (London and Paris) by using a date range. The historical (past) weather API is invoked because the DATE= and ENDDATE= options are specified. The concept of current conditions does not have any meaning when you specify past dates, so the historical weather data are returned instead of the current conditions. The output is shown in Output 54.6.1. When you specify past dates, the same data are returned whether or not you specify the CC= option. The SAS log shows the following warning:

*****WARNING: Using historical (past) weather API, so current conditions are 
not reported.



options validvarname=any;

title 'Historical Weather for Date Range MAY 01, 2017 - MAY 02, 2017 for
   London and Paris';
libname mylib "/sasusr/rain/doc/";

libname myRain saserain "%sysget(RAIN_DATA)"
   apikey='XXXXXXXXXXXXXXXXXXXX'
   query='London,United Kingdom;Paris,France'
   date='2017-05-01'
   enddate='2017-05-02'
   tp=24
   cc=onlycc
   format=XML
   outXml=rainex05
   automap=replace
   mapref=MyMap
   xmlmap="%SYSGET(RAIN_DATA)rainex05.map"
   ;

data mylib.cc3day;
   set myRain.rainex05;
run;
proc contents data=mylib.cc3day; run;
proc print data=mylib.cc3day; run;

Output 54.6.1: Historical Weather Data for Date Range for London and Paris

Historical Weather for Date Range MAY 01, 2017 - MAY 02, 2017 for London and Paris

ObsdateAreaNameCountryRegionoclatitudelongitudemaxtempCmaxtempFmintempCmintempFtotalSnow_cmsunHouruvIndextimetempCtempFwindspeedMileswindspeedKmphwinddirDegreewinddir16PointweatherCodeweatherDescprecipMMhumidityvisibilitypressurecloudcoverHeatIndexCHeatIndexFDewPointCDewPointFWindChillCWindChillFWindGustMilesWindGustKmphFeelsLikeCFeelsLikeF
12017-05-01LondonUnited KingdomCity of London, Greater London151.5170-0.1060015598470002415591017123ESE353Light rain shower2.8000085910037111518479481524948
22017-05-01ParisFranceIle-de-France248.86702.3330015598470002415591015231SW176Patchy rain possi1.7000067101010671253541115220321152
32017-05-02LondonUnited KingdomCity of London, Greater London151.5170-0.10600176284600024176291447NE353Light rain shower2.7000082101018401153847105013211050
42017-05-02ParisFranceIle-de-France248.86702.33300145854100024145861038NE176Patchy rain possi1.40000669101643105154110499151049


Last updated: August 11, 2020