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-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
  • 3 replies
  • 888 views
  • 0 likes
  • 2 in conversation