(View the complete code for this example.)
This example shows how to use the RANGE= option to retrieve severe storm warning data for a specific date. It also shows how to use the ID= option to read the message text for one ID (ID='397190'). When the ID= option is used, there are two output data sets. The first data set consists of the warning results data (named C1nco in the OUTXML= option), which contain the actual list of storm warnings for the date range that is specified in the RANGE= option. The second data set, C1nco_M, contains the text of the message ID specified in the ID= option, which in this example is 397190.
The output of the PRINT procedure for the Myc1nco data set is shown in Output 50.1.1.
options validvarname=any;
title 'Retrieve Warning Data with ID= Option for May 5, 2006';
libname mylib "/sasusr/noaa/doc/";
libname noaa sasenoaa "%sysget(NOAA_DATA)"
noaaset=warn
id='397190' /* create c1nco_m data set */
range='20060505:20060506'
outXml=c1nco /* create c1nco data set */
automap=replace
mapref=MyMap
xmlmap="%sysget(NOAA_DATA)cinco.map"
format=xml;
data mylib.myc1nco;
set noaa.c1nco;
run;
proc contents data=mylib.myc1nco; run;
proc print data=mylib.myc1nco(obs=5); run;
Output 50.1.1: NOAA Severe Storm Warnings with ID= Option for May 5, 2006
| Retrieve Warning Data with ID= Option for May 5, 2006 |
| Obs | ztime_start | ztime_end | id | warningtype | issuewfo | messageid | shape |
|---|---|---|---|---|---|---|---|
| 1 | 2006-05-04T11:57:00 | 2006-05-05T05:45:00 | 397088 | FLASH FLOOD | KSGF | 41157 | POLYGON ((-95.02 37.64, -95.02 37.02, -94.57 37.03, -94.59 36.52, -94.1 36.51, -94.12 37.62, -95.02 37.64)) |
| 2 | 2006-05-04T22:50:00 | 2006-05-05T00:15:00 | 397156 | SPECIAL MARINE | KLIX | 42251 | POLYGON ((-90.06 29.34, -89.8 29.15, -89.55 29.26, -89.61 29.27, -89.6 29.35, -89.67 29.31, -89.77 29.33, -89.75 29.41, -89.81 29.43, -89.83 29.49, -89.93 29.51, -89.94 29.48, -90.07 29.55, -90.17 29.51, -90.06 29.43, -90.06 29.34)) |
| 3 | 2006-05-04T22:50:00 | 2006-05-05T00:15:00 | 397157 | SPECIAL MARINE | KLIX | 42251 | POLYGON ((-90.06 29.34, -89.8 29.15, -89.55 29.26, -89.61 29.27, -89.6 29.35, -89.67 29.31, -89.77 29.33, -89.75 29.41, -89.81 29.43, -89.83 29.49, -89.93 29.51, -89.94 29.48, -90.07 29.55, -90.17 29.51, -90.06 29.43, -90.06 29.34)) |
| 4 | 2006-05-04T23:07:00 | 2006-05-05T00:00:00 | 397161 | SEVERE THUNDERSTORM | KSHV | 42307 | POLYGON ((-94.09 31.63, -94.04 31.6, -93.95 31.6, -93.93 31.61, -93.84 31.6, -93.8 31.71, -93.84 31.78, -94.11 31.78, -94.13 31.63, -94.09 31.63)) |
| 5 | 2006-05-04T23:10:00 | 2006-05-05T00:00:00 | 397162 | SEVERE THUNDERSTORM | KJAN | 42310 | POLYGON ((-91.57 33.33, -91.73 33.01, -91.17 33.02, -91.14 33.07, -91.2 33.14, -91.09 33.16, -91.14 33.29, -91.57 33.33)) |
The data sets, C1nco and C1nco_M, reside in the test folder, because the NOAA_DATA environment variable is defined to be the test folder, and that is the physical path given in the SASENOAA LIBNAME statement inside the double quotes:
libname noaa sasenoaa "/sasusr/noaa/test/"
Note: The DATA step that creates the Mylib.Myc1nco data set reads only the C1nco data into the document folder that is specified by the Mylib libref:
libname mylib "/sasusr/noaa/doc/";
But the other data set, which contains the message text data set, C1nco_M, is not copied into the document folder; instead it remains in the test folder where it was originally created by the SASENOAA engine. You could also copy it into the document folder using the following code:
libname myMes "/sasusr/noaa/test/";
data mylib.myc1nco_M;
set myMes.c1nco_M;
run;
You should not use the SASENOAA engine libref (NOAA) to access the already created SAS data set C1nco_M, because the message results were already placed in that data set automatically when you ran the example code to download the XML from the SWDI web service. The ID= option causes the SASENOAA engine to create the second data set, C1nco_M. After you read the data into SAS, you should use the normal Base SAS engine to access the resulting SAS data sets, by using the myMes libref in the SET statement that invokes the Base SAS engine.