|
If for some reason you wont use proc means or you want to do more
complex transformations, you could use a simple data step to solve
your problem ;-)
Please refine the code yourself, this is just a simple and quick hack.
data diag;
input @1 Diag0 @9 Diag1 @17 Diag2 @25 date $9.;
datalines;
1 0 0 05-Oct-98
0 1 0 05-Oct-98
1 0 0 06-Oct-98
0 1 0 06-Oct-98
0 1 0 06-Oct-98
1 0 0 06-Oct-98
1 0 0 06-Oct-98
0 1 0 06-Oct-98
1 0 0 10-Oct-98
0 1 0 11-Oct-98
1 0 0 12-Oct-98
0 1 0 12-Oct-98
0 0 1 13-Oct-98
1 0 1 13-Oct-98
0 0 0 13-Oct-98
;
run;
proc sort data=diag; by date; run;
data outout(keep=date all_admissions sum_diag0-sum_diag2);
set diag(keep=date diag0-diag2);
by date;
if first.date then
do;
all_admissions=0;
sum_Diag0=0;
sum_Diag1=0;
sum_Diag2=0;
end;
all_admissions+1;
sum_Diag0+Diag0;
sum_Diag1+Diag1;
sum_Diag2+Diag2;
if last.date then
output;
run;
|