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;
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 |
| Obs | date | AreaName | Country | Region | oc | latitude | longitude | maxtempC | maxtempF | mintempC | mintempF | totalSnow_cm | sunHour | uvIndex | time | tempC | tempF | windspeedMiles | windspeedKmph | winddirDegree | winddir16Point | weatherCode | weatherDesc | precipMM | humidity | visibility | pressure | cloudcover | HeatIndexC | HeatIndexF | DewPointC | DewPointF | WindChillC | WindChillF | WindGustMiles | WindGustKmph | FeelsLikeC | FeelsLikeF |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2017-05-01 | London | United Kingdom | City of London, Greater London | 1 | 51.5170 | -0.10600 | 15 | 59 | 8 | 47 | 0 | 0 | 0 | 24 | 15 | 59 | 10 | 17 | 123 | ESE | 353 | Light rain shower | 2.80000 | 85 | 9 | 1003 | 71 | 11 | 51 | 8 | 47 | 9 | 48 | 15 | 24 | 9 | 48 |
| 2 | 2017-05-01 | Paris | France | Ile-de-France | 2 | 48.8670 | 2.33300 | 15 | 59 | 8 | 47 | 0 | 0 | 0 | 24 | 15 | 59 | 10 | 15 | 231 | SW | 176 | Patchy rain possi | 1.70000 | 67 | 10 | 1010 | 67 | 12 | 53 | 5 | 41 | 11 | 52 | 20 | 32 | 11 | 52 |
| 3 | 2017-05-02 | London | United Kingdom | City of London, Greater London | 1 | 51.5170 | -0.10600 | 17 | 62 | 8 | 46 | 0 | 0 | 0 | 24 | 17 | 62 | 9 | 14 | 47 | NE | 353 | Light rain shower | 2.70000 | 82 | 10 | 1018 | 40 | 11 | 53 | 8 | 47 | 10 | 50 | 13 | 21 | 10 | 50 |
| 4 | 2017-05-02 | Paris | France | Ile-de-France | 2 | 48.8670 | 2.33300 | 14 | 58 | 5 | 41 | 0 | 0 | 0 | 24 | 14 | 58 | 6 | 10 | 38 | NE | 176 | Patchy rain possi | 1.40000 | 66 | 9 | 1016 | 43 | 10 | 51 | 5 | 41 | 10 | 49 | 9 | 15 | 10 | 49 |