As always: store dates as dates and you can use simple where-statements.
data have;
length id $ 10 First_Qual_Month Txn_Month $ 6;
input id First_Qual_Month Txn_Month;
datalines;
1000361 Jul-19 Jul-19
1000361 Jul-19 Aug-19
1000361 Jul-19 Sep-19
100897 Jan-20 Oct-19
100897 Jan-20 Nov-19
100897 Jan-20 Dec-19
100897 Jan-20 Jan-20
100897 Jan-20 Feb-20
100897 Jan-20 Mar-20
;
data fixed_dates;
set have;
length FirstQualMonth TxnMonth 8;
format FirstQualMonth TxnMonth mmyyd8.;
FirstQualMonth = input(First_Qual_Month, monyy6.);
TxnMonth = input(Txn_Month, monyy6.);
drop First_Qual_Month Txn_Month;
rename
FirstQualMonth = First_Qual_Month
TxnMonth = Txn_Month
;
run;
data want;
set fixed_dates;
where First_Qual_Month < Txn_Month;
run;
What should happen, if more than six obs have First_Qual_Month < Txn_Month ?
... View more