BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ARTI1
Calcite | Level 5

 

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?

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Can you show the community what the date macros are resolving to and data type of your start_dates

 

 

ARTI1
Calcite | Level 5

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

novinosrin
Tourmaline | Level 20

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;

ARTI1
Calcite | Level 5
Thank you! I had used single quotes and it threw me the same error.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2133 views
  • 0 likes
  • 2 in conversation