data want; set have; where dTran >= '01JAN2017'd and dTran <= '31JAN2017'd and cPOSMode in ('07') or (dTran >= '01JAN2017'd and dTran <= '31JAN2017'd and cPOSMode in ('90','02') and cToken is not null and cPvder is not null and idTReq is not null); run;
Is it possible to simplify the conditions by factoring out the dates?
Maybe
data want;
set have;
where dTran between '01JAN2017'd and '31JAN2017'd
and ( cPOSMode in ('07')
or (cPOSMode in ('90','02')
and cmiss(cToken, cPvder, idTReq) = 0) );
run;
/* Or */
data want;
set have;
where year(dTran) = 2017
and ( cPOSMode in ('07')
or (cPOSMode in ('90','02')
and cmiss(cToken, cPvder, idTReq) = 0) );
run;
Logical algebra:
A and B or A and C is equivalent to A and (B or C)
data want; set have; where dTran >= '01JAN2017'd and dTran <= '31JAN2017'd and (cPOSMode in ('07') or (cPOSMode in ('90','02') and cToken is not null and cPvder is not null and idTReq is not null)); run;
Hurm not sure whether it looks more readable.
Maybe
data want;
set have;
where dTran between '01JAN2017'd and '31JAN2017'd
and ( cPOSMode in ('07')
or (cPOSMode in ('90','02')
and cmiss(cToken, cPvder, idTReq) = 0) );
run;
/* Or */
data want;
set have;
where year(dTran) = 2017
and ( cPOSMode in ('07')
or (cPOSMode in ('90','02')
and cmiss(cToken, cPvder, idTReq) = 0) );
run;
Looking at historical doc, cmiss was introduced in base SAS in version 9.2
In what context and with what version of SAS are you calling cmiss?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.