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;
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.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.