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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.