Hello @alagiejatta,
Is it possible that duplicate dates occur for the same ID as in my sample data below for ID A99?
data have;
input ID $ (vr bd fx gh yz)(:mmddyy.);
format vr--yz mmddyy10.;
cards;
A11 1/2/1999 . 6/4/2012 8/1/2021 9/23/2019
A12 3/5/2021 . . . 3/5/2000
A13 3/5/2000 . . 4/17/1988 .
A14 10/24/1956 12/2/1967 1/6/2001 . .
A15 7/1/1996 11/7/1990 . 7/21/2001 6/10/2000
A99 9/23/2019 3/5/2000 4/17/1988 3/5/2000 1/2/1999
;
If not, you could populate the "slot" variables like this:
data want;
set have;
array _d[*] vr--yz;
array slot[5] $32;
do _n_=1 to n(of _d[*]);
slot[_n_]=vname(_d[whichn(smallest(_n_, of _d[*]), of _d[*])]);
end;
run;
(Only the name of the first of two or more variables containing the same date would occur in the "slots:" slot3=slot4='bd' for ID A99 in the example above.)
That said, I agree with the others who recommend a "long" data structure.
... View more