I have three date columns as shown in the 'have' table below. I would like to sort them and create a type variable that is the name of the date column (see the 'want' table).
In some cases, two dates may be equal in which case, they will only be counted as one date when sorting them, but both names should be included in the 'type' (see row 2 of 'want').
I came up with a very clunky way to do this with if/then statements, but I am wondering if there is a better way.
data have;
input A :yymmdd10. B :yymmdd10. C :yymmdd10. ;
format A B C yymmdd10.;
infile datalines delimiter=',';
datalines;
2019/01/01, 2018/03/13, .
2017/02/02, . , 2017/02/02
2018/11/18, 2018/08/01, 2021/07/02
;
run;
data want;
input date1 :yymmdd10. date2 :yymmdd10. date3 :yymmdd10. type1 $ type2 $ type3 $;
format date1 date2 date3 yymmdd10.;
infile datalines delimiter=',';
datalines;
2018/03/13, 2019/01/01, ., B, A, .
2017/2/2, . , . , A/B, . , .
2018/08/01, 2018/11/18, 2021/07/02, B, A, C
;
run;
... View more