BookmarkSubscribeRSS Feed
Nick9123
Calcite | Level 5

Keep getting an error "ERROR: Invalid date/time/datetime constant '01ju12020'd." The code used is below. I've used it multiple times in the past, but for some reason the error is only with " '01jul2020'd ". Suddenly only having this issue with the month of July.

 

I verified that the data is accurately formatted.

 

PROC SQL;
SELECT identification_number AS Product, 
consumer_account_number AS Loan, 
dateofaccountinformation AS DOAI, 
dateoflastpayment AS DOLP, 
actualpaymentamount FROM work.july2020
WHERE dateofaccountinformation BETWEEN '01ju12020'd AND '31jul2020'd AND dateoflastpayment BETWEEN '01ju12020'd AND '31jul2020'd AND actualpaymentamount = 000000000;
QUIT;
RUN;
2 REPLIES 2
Nick9123
Calcite | Level 5
Nevermind, just realized the issue was the " l " in jul was actually a 1. I will hang my head in shame.
ballardw
Super User

You might want to check your Dateofaccountinformation variable. You can get that error when the variable is a datetime and not a date value.

 

Example:

1    data junk;
2      dateofaccountinformation = "03Jul2020:12:15:13"dt;
3    run;

NOTE: The data set WORK.JUNK has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


4
5    proc sql;
6       select *
7       from junk
8       WHERE dateofaccountinformation BETWEEN '01ju12020'd AND
8  ! '31jul2020'd
ERROR: Invalid date/time/datetime constant '01ju12020'd.
9       ;
10   quit;
NOTE: The SAS System stopped processing this step because of
      errors.

 

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
  • 2 replies
  • 2392 views
  • 2 likes
  • 2 in conversation