I can't believe you need so many variables.
Check MERGE Skill proposed by me,Matt,Arthur.T
http://support.sas.com/resources/papers/proceedings15/2785-2015.pdf
data have;
infile cards truncover;
input ID (Ticket Date1 Date2 Code1 Code2 Code3 Code4 Code5) ($);
cards;
1 clm1 Jan Feb . V01 V02 E25
1 clm2 Feb Mar D01 . . C02
1 clm3 Mar Apr . . . B01 V02
2 clm1 Jan Mar . . . . B01
3 clm1 Jan May . B01 C01 . D01
3 clm2 Feb Jun . . V01 E02 .
;
run;
data temp;
set have;
by id;
if first.id then n=0;
n+1;
array x{*} $ code:;
x1=scan(catx('|',of x{*}),1,'|');
x2=scan(catx('|',of x{*}),2,'|');
keep id ticket date1 date2 x1 x2 n;
run;
proc freq data=temp noprint;
table n/out=key nopercent;
run;
data _null_;
set key end=last;
if _n_=1 then call execute('data want;merge ');
call execute(catt('temp(where=(n=',n,') rename=(ticket=ticket_',n,'
date1=date1_',n,' date2=date2_',n,' x1=x1_',n,' x2=x2_',n,'))'));
if last then call execute(';by id;drop n;run;');
run;
... View more