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;
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 );
what is your ERROR Log ?
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.
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 );
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.