@Ksharp wrote:
data have;
infile cards dsd;
informat site $4. datetime datetime. precipitationtype $3.;
format site $4. datetime datetime. precipitationtype $3.;
input site datetime precipitationtype;
cards;
kbos,01JAN2016:05:00:00,-RA
kbos,01JAN2016:05:01:00,-RA
kbos,01JAN2016:05:10:00,+RA
kacy,03JAN2016:07:20:00,-SN
kacy,03JAN2016:07:51:00,SN
kacy,03JAN2016:07:52:00,+SN
kbos,03JAN2016:16:21:00,-RA
kbos,03JAN2016:16:22:00,-RA
kbos,03JAN2016:16:26:00,+RA
kacy,04JAN2016:05:20:00,-SN
kacy,04JAN2016:07:51:00,SN
kacy,04JAN2016:07:52:00,+SN
;
run;
data temp;
set have;
date=datepart(datetime);
type=compress(precipitationtype,,'ka');
format date date9.;
run;
proc sql;
create table want as
select site,date,sum(type='RA') as RA,sum(type='SN') as SN,count(*) as total
from temp
group by site,date;
quit;
Thanks very much! I was not aware that proc sql allowed conditions (type='SN') in the select statement. That's very handy.
Thanks again, Bruce
... View more