Use quotations followed by d (if using only date - dt, if you're using datetime), and write the date case as "19May15"d (it won't work with "19/05/15"d): /* ===================================== */
/* Date */
DATA subset_by_date;
INPUT id name $ date;
INFORMAT date ddmmyy8.;
FORMAT date ddmmyy8.;
DATALINES;
101 xxx 19/05/15
102 YYY 19/06/16
103 zzz 19/05/15
;
RUN;
DATA works;
SET subset_by_date;
WHERE date = '19May15'd;
RUN;
* Returns only ids 101 and 103;
DATA works_too;
SET subset_by_date;
WHERE '18MAY15'D < date < '20May15'd;
RUN;
* Returns only ids 101 and 103;
DATA wont_work;
SET subset_by_date;
WHERE date = '19/05/15'd;
RUN;
* ERROR: Invalid date/time/datetime constant '19/05/15'd. ;
/* ===================================== */
/* Datetime */
DATA subset_by_datetime;
INPUT id name $ datetime;
INFORMAT datetime anydtdtm40.;
FORMAT datetime datetime.;
DATALINES;
101 xxx 19/05/15
102 YYY 19/06/16
103 zzz 19/05/15
;
RUN;
DATA works_datetime;
SET subset_by_datetime;
WHERE datetime = '16Jun19:00:00:00'dt;
RUN;
* Returns only id 102 ;
... View more