************************************************************************ weather_post_process.sas Perfoms post-process changes to raw data output from CR10 weather station program MLBS1.DLD Sample CR10 raw data output - 30,2002,189,1330,11.53,28.69,24.2,80.4,893,1.23,277.4,0,1117 30,2002,189,1400,12.82,28.64,24.01,80.8,893,1.449,294.3,0,706 30,2002,189,1430,12.84,28.21,23.72,81.8,893,1.282,321.3,0,921 30,2002,189,1500,12.86,28.04,24.47,78.8,893,1.466,295.8,0,862 30,2002,189,1530,12.87,28.31,24.21,80.6,892,1.375,317.8,0,788 30,2002,189,1600,12.87,28.51,24.15,80.6,892,1.401,303.4,0,550.8 Comma-delimited variables - data saving interval (30 minutes) drop year no change julian date format number 000 time format number 0000 battery voltage drop internal temperature drop external temperature format number .000 humidity truncate to 100%, format number .0 pressure no change wind speed set 0.447 offset to 0, format number .000 wind direction format number .0 precipitation format number .000 PAR set neg values to 0, format number .0 1) copy raw output data to in.dat (no need to remove commas) 2) corrected data output to out.dat 3) out.dat can be appended to data for distribution 4) must add header manually: OUTPUT VARS - Station Year Date Time Temp Humid Pres Speed Dir Rain hv ESN 02 November 2000 02 August 2002 14 October 2002 26 June 2003 added better missing value conversions ************************************************************************; options ls=75 ps=53; ***** NOTE - be careful to change drive letter and/or path when working on different machines; data one; infile 'C:\Data\E\Mountain_Lake\Data Bases\Weather Data\Weather Station - MLBS1\New Raw Data\in.dat' dsd; input interval year date time volt itemp etemp humid pres speed dir precip par ; if humid > 100 then humid = 100 ; if humid = -6999 then humid = '.' ; if humid < 1 then humid = '.' ; if etemp < -1000 then etemp = '.' ; if speed = 0.447 then speed = 0.000 ; if par < 0 then par = 0 ; station = 'MLBS1'; file 'C:\Data\E\Mountain_Lake\Data Bases\Weather Data\Weather Station - MLBS1\New Raw Data\out.dat'; *** date < 10 ***; if date < 10 and time < 100 then put @1 station @11 year 4.0 @21 2*'0' date @31 2*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if date < 10 and 100 <= time < 1000 then put @1 station @11 year 4.0 @21 2*'0' date @31 1*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if date < 10 and 1000 <= time then put @1 station @11 year 4.0 @21 2*'0' date @31 time 4.0 @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; *** 10 <= date < 100 ***; if 10 <= date < 100 and time < 100 then put @1 station @11 year 4.0 @21 1*'0' date @31 2*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if 10 <= date < 100 and 100 <= time < 1000 then put @1 station @11 year 4.0 @21 1*'0' date @31 1*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if 10 <= date < 100 and 1000 <= time then put @1 station @11 year 4.0 @21 1*'0' date @31 time 4.0 @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; *** 100 <= date ***; if 100 <= date and time < 100 then put @1 station @11 year 4.0 @21 date 3.0 @31 2*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if 100 <= date and 100 <= time < 1000 then put @1 station @11 year 4.0 @21 date 3.0 @31 1*'0' time @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; if 100 <= date and 1000 <= time then put @1 station @11 year 4.0 @21 date 3.0 @31 time 4.0 @41 etemp 7.3 @51 humid 5.1 @61 pres 3.0 @71 speed 7.3 @81 dir 5.1 @91 precip 7.3 @101 par 7.1 ; run;