****************************************************************** weather_summary.sas Program to summarize MLBS meteorological data. Generates tables of monthly statistics and an output data file for use in generating monthly charts of daily statistics. INPUT ####.dat raw data file for year SAS OUTPUT tables of summary statistics. OUTPUT file ####dmeans.dat summary data by day for that year. ####dmeans.dat then converted to ####dmeans.xls Excel file. 5 'sheets' are generated with figures in Excel. Workbook is 'saved as' ####.html. *.GIF files are extracted from folder generated by Excel. GIF files uploaded to web. ESN 08-Oct-1997 revised 09-Nov-2000 to produce output for graphing. 19-Jan-2001 29-Jan-2001 26-Jul-2002 *****************************************************************; options ps=55 ls=75; *** EDIT OUTPUT FILES NAME IN INFILE STATEMENT; *** MAKE NEEDED PATH AND DISK DRIVE CORRECTIONS; data use1; *** input raw data from downloadable yearly .DAT files ***; infile 'C:\Data\E\Mountain_Lake\Data Bases\Weather Data\Weather Station - MLBS1\Data for Distribution\2003.dat' firstobs=2; input station $ year date time temp humid pres speed dir rain hv; if date>0 and date<32 then month='January '; if date>31 and date<60 then month='February' ; if date>59 and date<91 then month='March' ; if date>90 and date<121 then month='April' ; if date>120 and date<152 then month='May' ; if date>151 and date<182 then month='June' ; if date>181 and date<213 then month='July' ; if date>212 and date<244 then month='August' ; if date>243 and date<274 then month='September'; if date>273 and date<305 then month='October' ; if date>304 and date<335 then month='November' ; if date>334 and date<366 then month='December' ; if year/4=int(year/4) then do; **** for leap year ****; if date>0 and date<32 then month='January '; if date>31 and date<61 then month='February' ; if date>60 and date<92 then month='March' ; if date>91 and date<122 then month='April' ; if date>121 and date<153 then month='May' ; if date>152 and date<183 then month='June' ; if date>182 and date<214 then month='July' ; if date>213 and date<245 then month='August' ; if date>244 and date<275 then month='September'; if date>274 and date<306 then month='October' ; if date>305 and date<336 then month='November' ; if date>335 and date<367 then month='December' ; end; *******************************************************; *** For monthly and yearly summary tables. ***; proc means max min mean sum n; title 'Yearly Statistics'; var temp humid speed rain hv; proc sort; by month; proc means max min mean sum n; title 'Monthly Statistics'; by month; var temp humid speed rain hv; ********************************************************; ********************************************************; *** For yearly charts. Statistics calculated by day. ***; proc sort; by date; proc means mean sum noprint; title 'Daily statistics for year to date'; by date; var temp humid speed rain hv; id year month; output out=temp1 mean=mtemp mhumid mspeed mrain mhv sum=stemp shumid sspeed srain shv ; *** EDIT OUTPUT FILES NAME IN FILE STATEMENT; data use4; set temp1; file 'C:\Data\E\Mountain_Lake\Data Bases\Weather Data\Weather Station - MLBS1\Data for Distribution\2003dmeans.dat'; put @1 year 4.0 @10 month @25 date 3.0 @35 mtemp 7.3 @45 mhumid 5.1 @55 mspeed 7.3 @65 srain 7.3 @75 mhv 5.1 ; ******************************************************************; *** You can then import data file '####dmeans.dat' into Excel. Chart wizard used to generate basic charts of means and sums. ***; ******************************************************************; run;