Check the MERGE skill proposed by me, Arthur.T and Matt :
http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf
And could you post your sample data and the desired output to explain this question better?
data have;
input id char $ num date :date9. time :time. ;
format date date9. time time.;
cards;
1 ss 23 1jan2010 09:20:21
1 ss 24 2jan2010 09:20:22
1 ss 25 3jan2010 09:20:23
2 ss 26 4jan2010 09:20:24
2 ss 27 5jan2010 09:20:25
;
data temp;
set have;
by id;
if first.id then n=0;
n+1;
run;
proc sql noprint;
select distinct(catt('temp(where=(n=',n,') rename=(
char=char_',n,' num=num_',n,' date=date_',n,' time=time_',n,'))'))
into :merge separated by ' '
from temp;
quit;
data want;
merge &merge ;
by id;
drop n;
run;
And a more simple and convenient way is using proc summary+idgroup, but it has limit that each group have 100 obs at most.
data have;
input id char $ num date :date9. time :time. ;
format date date9. time time.;
cards;
1 ss 23 1jan2010 09:20:21
1 ss 24 2jan2010 09:20:22
1 ss 25 3jan2010 09:20:23
2 ss 26 4jan2010 09:20:24
2 ss 27 5jan2010 09:20:25
;
proc sql noprint;
select max(n) into :n from
(select count(*) as n from have group by id);
quit;
proc summary data=have nway;
class id;
output out=want idgroup( out[&n] (char num date time)=);
run;
... View more