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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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