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

Hi All,

I am facing problem in resolving date variable for given calculation; please find code below. But it is giving me error. Any help is really appreciated....

    

PROC SQL NOPRINT;
SELECT * FROM FACT WHERE
FACT.INCEP_DT  BETWEEN (&NEXT_REP_PERIOD_START 
AND &NEXT_REP_PERIOD_END);
QUIT;

PROC SQL;
SELECT MIN(STRT_DT) FORMAT=DATETIME20. INTO :NEXT_REP_PERIOD_START
FROM PRD
WHERE  YEARR  =  2012;
SELECT MIN(END_DT) FORMAT=DATETIME20. INTO :NEXT_REP_PERIOD_END
FROM PRD
WHERE  YEARR  =  2012;
QUIT;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Oh. That is not SAS datetime constant. you should use some syntax like '01jan2012:00:00:00'dt to pass it.

FACT.INCEP_DT  BETWEEN ( "&NEXT_REP_PERIOD_START"dt

        AND "&NEXT_REP_PERIOD_END"dt   );

View solution in original post

3 REPLIES 3
Ksharp
Super User

what is your ERROR Log ?

forumsguy
Fluorite | Level 6

Hi Ksharp

Following is my error log

PROC SQL NOPRINT;
16         SELECT * FROM  FACT WHERE
17         FACT.INCEP_DT  BETWEEN (&NEXT_REP_PERIOD_START
18         AND &NEXT_REP_PERIOD_END);
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
NOTE: Line generated by the macro variable "NEXT_REP_PERIOD_START".
18           01JAN2012:00:00:00
               _______
               22
               76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, ), *, **, +, -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
              CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=. 

ERROR 76-322: Syntax error, statement will be ignored.

Ksharp
Super User

Oh. That is not SAS datetime constant. you should use some syntax like '01jan2012:00:00:00'dt to pass it.

FACT.INCEP_DT  BETWEEN ( "&NEXT_REP_PERIOD_START"dt

        AND "&NEXT_REP_PERIOD_END"dt   );

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1512 views
  • 0 likes
  • 2 in conversation