80 likes | 232 Views
Using SAS to Obtain Tornado GIS Data from the National Weather Center. Valentin Todorov Statistician Assurant Specialty Property. Agenda. Severe weather database at NWC filename statement in a nutshell SAS macro to get reports from NWC Final results Other uses of the filename statement.
E N D
Using SAS to Obtain Tornado GIS Data from the National Weather Center Valentin Todorov Statistician Assurant Specialty Property
Agenda • Severe weather database at NWC • filename statement in a nutshell • SAS macro to get reports from NWC • Final results • Other uses of the filename statement
Severe Weather Database at NWC • Serves as the official record keeper for tornado, wind and hail occurrences in the USA • Provides detailed information for severe weather events • GIS data: Latitude and longitude of the location • Event characteristics: Strength, direction and trajectory • Updates daily • Reports are stored in .CSV format and can be downloaded from: http://www.spc.noaa.gov/climo/reports/090916_rpts_torn.csv Date of Report
filename Statement in a Nutshell • filename Refresher • File Access Method - http filename fileref <device-type> <'external-file'> <options>; filename fileref http “http://www...”; proc import datafile =; input …;
SAS Macro to Get Reports from NWC %macro tornado(daydate); filename NOAAfile HTTP "http://www.spc.noaa.gov:80/climo/reports/&daydate._rpts_torn.csv"; proc import datafile = "NOAAfile" out= TORNADO.file&daydate. dbms=CSV replace; run; data TORNADO.file&daydate.; set TORNADO.file&daydate.; length F_Scale1 $3. Location1 $20. County1 $13. Comments1 $230.; Longitude=input(Lon,12.); Latitude=input(Lat,12.); F_Scale1=F_Scale; Location1=Location; County1=County; Comments1=Comments; drop F_Scale Location County Comments; date="&daydate"; run; %mend; %tornado(090907); %tornado(090906); %tornado(090905); %tornado(090904); …………………….. %tornado(090101); Location of reports GIS Coordinates Invoke the Macro above by changing the report date
Other Uses of the filename Function • Obtain stock quotes from Yahoo! Finance1 • Access remote files by using the FTP protocol2 filename in url “http://finance.yahoo.com:80/d/quotes.txt?s=YHOO+IBM+HPQ&f=sl1d1t1c1ohgv&e=.txt”; data; infile in dsd end=eof termstr=crlf; input Ticker : $4. Price TradeDate : $10. TradeTime: $7. Change Open Hi Lo Volume; options nodate nonumber nocenter ls=70; run; filename in ftp ‘datafile' cd='/techsup/download/datastep/' user='anonymous' host='ftp.sas.com'; data inDataFile; infile in; input x $10. y 4.; run; 1 SUGI Paper 73-28, The URL-y Show: Using SAS LE and the URL Access Method to Retrieve Stock Quotes, Ted Conway 2 SUGI Paper 007-2007, The File Name Revisited, Yves DeGuire, Statistics Canada