Merge Skill:
data have;
input ID D_DATE :mmddyy10. AA BB CC DD;
format D_DATE mmddyy10.;
cards;
1 6/10/2015 5 4 0 0
1 7/10/2015 7 0 0 3
1 9/10/2015 0 0 3 0
1 6/10/2015 5 4 0 0
1 7/10/2015 7 0 0 3
1 9/10/2015 0 0 3 0
1 6/10/2015 5 4 0 0
1 7/10/2015 7 0 0 3
1 9/10/2015 0 0 3 0
1 6/10/2015 5 4 0 0
1 7/10/2015 7 0 0 3
1 9/10/2015 0 0 3 0
2 10/2/2015 0 1 0 3
2 10/30/2015 0 0 0 0
2 12/10/2015 0 3 0 0
3 1/8/2016 0 0 5 3
3 2/19/2016 0 2 0 0
4 3/11/2016 0 0 6 0
4 4/7/2016 0 2 0 0
5 5/11/2016 0 0 0 3
5 6/16/2016 0 0 0 0
;
data temp;
set have;
by id;
if first.id then n=0;
n+1;
run;
proc sql noprint nowarn;
select distinct catt('temp(where=(n=',n,') rename=(
d_date=d_date',n,' aa=aa',n,' bb=bb',n,' cc=cc',n,' dd=dd',n,'))')
into : merge separated by ' '
from temp
order by n;
quit;
data want;
merge &merge;
by id;
drop n;
run;
... View more