where pay_quarter in ('2019Q1'd, '2021Q1'd);
This comparison of a variable to specific values fails for two reasons.
The comparison is always done with UNformatted values, and so even though the value of pay_quarter may appear to you as 2019Q1, the underlying date may in fact be '15JAN2019'd or '16JAN2019'd or any other date in the first quarter of 2019. Second reason it fails is that '2019Q1'd is a meaningless construct in SAS and should produce an error. So, a possible comparison might be
where pay_quarter in ('01JAN2019'd,'02JAN2019'd,'03JAN2019'd, ... );
which is invalid code because of the triple dots, but you get the idea, no one wants to type out all of the days in the first quarter, that would be 91 days ... you get the point.
Here is valid code:
where '01JAN2019'd<=pay_quarter<='31MAR2019'd or '01JAN2021'd<=pay_quarter<='31MAR2021'd;
Alternatively, you can use the INTNX function
where intnx('month',pay_quarter,0,'b') in ('01JAN2019'd,'01JAN2021'd);
which converts any day to the very first day of the quarter and then you can do the comparison to '01JAN2019'd (that's the first day of the quarter of interest) or to '01JAN2021'd (also the first day of the quarter of interest).
Alternatively, @Reeza shows how to do this with the PUT function.
If you are going to work with dates that are formatted, the RED above is a key piece of information that you must understand and use.
--
Paige Miller