SASERAIN Interface Engine
The LIBNAME libref SASERAIN Statement
LIBNAME libref SASERAIN 'physical-name' options;
The LIBNAME statement assigns a SAS library reference (libref) to the physical path of the directory of World Weather Online data files in which the downloaded World Weather Online XML data are stored. The required physical-name argument specifies the location of the folder where your World Weather Online XML data reside. It should end with a backslash if you are in a Windows environment and a forward slash if you are in a UNIX environment.
You can specify the following options in the LIBNAME libref SASERAIN statement.
- APIKEY='rain_apikey'
-
specifies the World Weather Online authentication token or access key that enables you to access the data that the World Weather Online website provides. This access key is a 29-character mixed-case alphanumeric string, and it is required. It must be enclosed in single quotation marks. You can request your rain_apikey by visiting the website at the following URL:
https://www.worldweatheronline.com/developer/signup.aspx
- AUTOMAP=REPLACE | REUSE
-
specifies whether or not to overwrite the existing XML map file.
- REPLACE
specifies that the XML map file be overwritten, and ensures that the most current XML map that is generated by the SASERAIN engine and named by the XMLMAP= option is used.
- REUSE
specifies that the XML map file not be overwritten, and ensures that a pre-existing XML map file that is named by the XMLMAP= option is used.
By default, AUTOMAP=REPLACE.
- CONDITIONS=ONLYCC | YES | NO
-
specifies whether or not to return only current conditions data. CONDITIONS=ONLYCC enables the SASERAIN interface to output the current conditions data but not the forecast data. For more about current conditions, see Table 2.
- ONLYCC
specifies that only the current conditions be output.
- YES
specifies that the current conditions be output.
- NO
specifies that the current conditions variables be excluded from the output.
By default, the SASERAIN engine uses CONDITIONS=NO and FORECAST=YES. Specify CONDITIONS=YES to create both the current conditions output data set (named in the OUTCC= option) and the weather forecast output data set (named in the OUTXML= option). When the OUTCC= option is not specified, the prefix 'CC_' is added to the name specified in the OUTXML= option. For more information, see the FORECAST= and OUTCC= options. The SASERAIN engine issues a warning when both past weather and current conditions are selected in the same SASERAIN LIBNAME statement.
Table 2: Current Conditions Forecast Variables
Variable Name Description observation_time Time in UTC hhmm ttformat. For example: 06:45 AM or 11:34 PM.temp_C Temperature in degrees Celsius windspeedMiles Wind speed in miles per hour windspeedKmph Wind speed in kilometers per hour winddirDegree Wind direction in degrees winddir16Point Wind direction on a 16-point compass weatherCode Weather condition code weatherDesc Weather condition description weatherIconUrl URL for weather icon precipMM Precipitation in millimeters precipInches Precipitation in inches humidity Humidity in percentage visibility Visibility in kilometers visibilityMiles Visibility in miles pressure Atmospheric pressure in millibars pressureInches Atmospheric pressure in inches cloudcover Cloud cover in percentage
- CONNECT=ON | OFF
-
specifies whether or not to use the connect method along with the PROXY= option. Note: You must use the PROXY= option and specify your proxy server in addition to the CONNECT=ON option when you want to use the connect method. For more information about a secure connection, see the PROXY= option.
- DATE=rain_date_start
-
specifies the start date for requesting past (historical) weather data: specify
YYYY-MM-DD(format for the rain_date_start). The earliest start date for premium users is July 1, 2008. - DAY=TODAY | TOMORROW
-
specifies the start date for the local current weather forecast: specify today or tomorrow, but results are the same—they start today. If you want a start date other than today, then use the DATE= option. Use the NUM_OF_DAYS= option to specify the number of days to report.
- DEBUG=ON | OFF
-
specifies whether or not to include diagnostic message logging in the SAS log window. This information can be very useful for troubleshooting a problem.
- ENDDATE=rain_date_enddate
-
specifies the end date for the range to report past weather:
YYYY-MM-DD(format for the rain_date_enddate). The earliest start date (which you specify in the DATE= option) for premium past weather is July 1, 2008, but the ENDDATE= option must have the same month and year as the start date. The date must be enclosed in single quotation marks. The ENDDATE= optionis not required, and the default range is 2 days.
- FORECAST=YES | NO
-
specifies whether or not to return the weather forecast for a given location (city and country, postal code, zip code, or latitude and longitude values). By default, the SASERAIN engine uses FORECAST=YES. For more about weather forecast variables, see Table 3. When the type of data is not specified in the LIBNAME statement options, the SASERAIN engine defaults to normal weather forecast data and automatically defaults to the FX=YES option. Use either the FX24= option or the FX= option (but not both). When you specify FX24=YES, you do not need to specify any interval (FREQ= option) or any range specification, because the default is 24 hours of data at an interval of every 3 hours (and an extra observation for the 24-hour average).
Table 3: Weather Forecast Variables
Variable Name Description date Local forecast date in YYYY-MM-DDformat. For example: 2013-05-31.maxtempC Maximum temperature of the day in degrees Celsius maxtempF Maximum temperature of the day in degrees Fahrenheit mintempC Minimum temperature of the day in degrees Celsius mintempF Minimum temperature of the day in degrees Fahrenheit uvIndex Ultraviolet radiation index time Local time in hmmformat. For example: 100 or 1500.tempC Temperature in degrees Celsius tempF Temperature in degrees Fahrenheit windspeedMiles Wind speed in miles per hour windspeedKmph Wind speed in kilometers per hour windspeedKnots Wind speed in knots windspeedMeterSec Wind speed in meters per second winddirDegree Wind direction in degrees winddir16Point Wind direction on a 16-point compass weatherCode Weather condition code weatherDesc Weather condition description weatherIconUrl URL for weather icon precipMM Precipitation in millimeters precipinches Precipitation in inches humidity Humidity in percentage visibility Visibility in kilometers visibilityMiles Visibility in miles pressure Atmospheric pressure in millibars pressureInches Atmospheric pressure in inches cloudcover Cloud cover in percentage chanceofrain Chance of rain (precipitation) in percentage chanceofwindy Chance of being windy in percentage chanceofovercast Chance of being cloudy in percentage chanceofsunny Chance of being sunny in percentage chanceoffrost Chance of frost in percentage chanceoffog Chance of fog in percentage chanceofsnow Chance of snow in percentage chanceofthunder Chance of thunder in percentage
- FORMAT=XML
-
specifies the format of the file to be retrieved from the World Weather Online website. Although World Weather Online can report data in many formats, the SASERAIN engine supports only the XML format.
- FREQ=DAILY | HOURLY | 3HOURLY | 6HOURLY | 12HOURLY | 24HOURLY | DAY/NIGHT
-
specifies the frequency of the weather data. In World Weather Online weather forecast data, the highest frequency is hourly, and the lowest frequency is daily.
The FREQ= option is not required, and the default interval value is 6 hours.
- FX24=YES | NO
-
specifies whether or not to return the 24-hour weather forecast at a three-hour interval for city/country, postal code, zip code, and latitude/longitude values. By default, the SASERAIN engine uses FX24=NO. When the type of data is not specified in the LIBNAME statement options, the SASERAIN engine defaults to normal weather forecast data and automatically defaults to the FX=YES option. Note: Use either the FX24= option or the FX= option (but not both). When you specify FX24=YES, you do not need to specify any interval (FREQ= option) or any range specification, because the default is 24 hours of data at an interval of 3 hours, but there is also an extra observation for the 24-hour averages for the reported variables.
- MAPREF=rain_xmlmapref
-
specifies the fileref to use for the map assignment. For an example of the SASERAIN engine that uses the MAPREF= and XMLMAP= options in the FILENAME statement in order to assign a file name, as in the following statement, see the section Examples: SASERAIN Interface Engine:
FILENAME MyMap "/sasusr/rain/test/gstart.map";You can use the MAPREF= and XMLMAP= options to control where the map resides, what you name the map, and how you refer to it with a fileref. You can use the OUTXML= option to name your XML data file. It is placed in the current working folder. The SAS data set that is created (when the XML data are read into SAS) is placed in the folder specified by physical-name, and you can reference it by using the myLib libref in your SASERAIN LIBNAME statement. This is shown in the section Examples: SASERAIN Interface Engine, inside the DATA step in the SET statement. The SET statement reads observations from the input data set
myLib.GSTARTand stores them in a SAS data set namedHowCool. - NUM_OF_DAYS=rain_numdays
-
specifies the number of days to report local weather (starting from today). The maximum is 15 days.
- OUTCC=rain_outcc
-
specifies the name of the SAS data set where the current conditions data that are returned from the World Weather Online website are stored. When OUTCC= option is not specified, the SASERAIN interface stores the current conditions data in a SAS data set named by adding the prefix 'CC_' to the name specified in the OUTXML= option. If there is no request for current conditions data, then the OUTCC= option is ignored.
- OUTXML=rain_xmlfile
-
specifies the name of both the XML file (downloaded) and the SAS data set created when the XML data are read into SAS. Each World Weather Online location code that is listed in the QUERY= option is given a positional numeral: 1 for the first code in the QUERY= option, 2 for the second code, and so on. The SASERAIN engine appends this numeral to the file name of the XML of each data set that the website returns. When all the XML files are retrieved, the data are merged into a SAS data set. When only one World Weather Online location code is specified in the QUERY= option, the file name has the numeral 1 appended to the OUTXML file name. By default, OUTXML=RAIN, which creates a file named
RAIN1.xmlin the current working directory. The SAS data set that is created when the XML data are read into SAS is placed in the folder specified by the physical path in the LIBNAME libref SASERAIN statement. - PROXY="rain_proxyserver"
-
specifies which proxy server to use. This option is not required. The specified proxy server is used only when a connection-refused error or a connection-timed-out error occurs. For rain_proxyserver, specify the server’s HTTP address followed by a colon and the port number, and enclose that string in double quotation marks; for example, PROXY="http://inetgw.unx.sas.com:8118". See also the CONNECT= option.
- QUERY=‘rain_qcode_list’
-
specifies the list of World Weather Online locations for the data sets that contain the time series to be included in the output SAS data set. There is a limit of nine World Weather Online location codes in the QUERY= option. The argument ‘rain_qcode_list’ is semicolon-delimited and must be enclosed in single quotation marks. For example:
QUERY='QCODE1;QCODE2;...QcodeN'}
Each
QCODEspecifies a weather data location in one of the following location formats:- Latitude,Longitude
specifies the location of the selected weather forecast in decimal degrees (XX.XXX,XX.XXX).
- UScityName,State
specifies the location of the selected US city and state.
- cityName,Country
specifies the location of the selected city in the specified country, or if the location is in the United States, you can specify cityName,State.
- IPaddress
specifies the location by using the Internet Protocol address in XXX.XXX.XXX.XXX format.
- USzipcode
specifies the location by using the US zip code format.
- UK_CANpostalcode
specifies the location by using the United Kingdom or Canadian postal code format.
You can specify a maximum of nine q-code locations in the QUERY= option, separated by semicolons. Each q-code can contain commas, blanks, or both. The QUERY= option is required.
- TP=1 | 3 | 6 | 12 | 24
-
specifies the number of hours in a time period. In World Weather Online weather forecast data, the highest frequency is 1 (hourly), and the lowest frequency is 24 (daily).
The TP= option is not required, and the default interval value is 6 hours.
- XMLMAP=rain_xmlmapfile
specifies the fully qualified name of the location where the XML map file is automatically stored.