BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Rixile106
Fluorite | Level 6

Good expects.

 

please assist with the syntax of the below code as i am getting this error message
ERROR: Syntax error while parsing WHERE clause.

DATA WANT;
SET  HAVE ;
WHERE Account_Open_Dt BETWEEN 01JANB2022 AND 28FEB2022 ;

RUN;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

SAS does not know what 01JANB2022 AND 28FEB2022 means. These can't be variable names because they start with a digit, and they are not text strings because they are no enclosed in quotes. So SAS is stumped.

 

What you probably want is this (and note, I have fixed a typographical error in your code as well)

 

WHERE Account_Open_Dt BETWEEN '01JAN2022'd AND '28FEB2022'd;

 

When you have a date enclosed in quotes and followed by the letter d then SAS understands you mean these to be actual dates. Also please note the format within the quotes, you have to use this exact format, 2 digit day, 3 letter month and 4 digit year, without change or alteration (except that the month can be lower case).

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

SAS does not know what 01JANB2022 AND 28FEB2022 means. These can't be variable names because they start with a digit, and they are not text strings because they are no enclosed in quotes. So SAS is stumped.

 

What you probably want is this (and note, I have fixed a typographical error in your code as well)

 

WHERE Account_Open_Dt BETWEEN '01JAN2022'd AND '28FEB2022'd;

 

When you have a date enclosed in quotes and followed by the letter d then SAS understands you mean these to be actual dates. Also please note the format within the quotes, you have to use this exact format, 2 digit day, 3 letter month and 4 digit year, without change or alteration (except that the month can be lower case).

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 657 views
  • 2 likes
  • 2 in conversation