Naming a variable "Proc" can cause confusion, so i changed it to "method".
Thanks @average_joe for providing data in a useful form.
data want(keep= ID Method Date);
set have;
length Method $ 30 Date 8;
format Date yymmddd10.;
d = countw(Dates, '|');
p = countw(Procedures, '|');
if d ^= p then do;
put 'ERROR: Number of values in Dates/Procedures is not the same.';
stop;
end;
do i = 1 to p;
Method = scan(Procedures, i, '|');
if Method = 'Orthopedic' then do;
Date = input(scan(Dates, i, '|'), yymmdd10.);
output;
end;
end;
run;
I would inquire, why the data was created in such an ugly and useless structure in the first place.
... View more