DATA Step, Macro, Functions and more

Date in Macro Variable

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 85
Accepted Solution

Date in Macro Variable

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;


Accepted Solutions
Solution
‎03-30-2012 03:29 AM
Super User
Posts: 9,681

Date in Macro Variable

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


All Replies
Super User
Posts: 9,681

Date in Macro Variable

what is your ERROR Log ?

Frequent Contributor
Posts: 85

Date in Macro Variable

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.

Solution
‎03-30-2012 03:29 AM
Super User
Posts: 9,681

Date in Macro Variable

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   );

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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