Have created two date Macros to take out a subset of a huge dataset. Below is the code
data Start rest ;
set Start3;
if start_date2 GE &fildt1. and start_date2 LE &fildt2. then output start;
else output rest;
run;
The date macros are producing proper dates but the If condition is throwing error
The error I am getting is
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>,
=, >, ><, >=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |,
||, ~=.
ERROR 388-185: Expecting an arithmetic operator.
ERROR 76-322: Syntax error, statement will be ignored.
What am I doing wrong here?
Can you try the change below
data Start rest ;
set Start3;
if start_date2 GE "&fildt1."d and start_date2 LE "&fildt2."d then output start;
else output rest;
run;
Can you show the community what the date macros are resolving to and data type of your start_dates
SYMBOLGEN: Macro variable FILDT1 resolves to 27SEP2018
NOTE: Line generated by the macro variable "FILDT1".
335 27SEP2018
-------
22
SYMBOLGEN: Macro variable FILDT2 resolves to 03OCT2018
NOTE: Line generated by the macro variable "FILDT2".
335 03OCT2018
Can you try the change below
data Start rest ;
set Start3;
if start_date2 GE "&fildt1."d and start_date2 LE "&fildt2."d then output start;
else output rest;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.