Hello all, I am working with the code below and I keep getting the error. ERROR: Invalid date/time/datetime constant "stdft."d. I have checked my
formats and they are all the same and I just can't seem to figure out what is causing the error?
data dates;
infile datalines delimiter = ',';
input ID $ DATE:anydtdte11. COND STDT:anydtdte11. ENDT:anydtdte11. ;
format date stdt endt mmddyy10.;
datalines;
1, 05/03/2018, ., 05/03/2017, 05/03/2018
1, 05/02/2018, ., 05/02/2017, 05/03/2018
2, 04/26/2018, 1, 04/26/2017, 04/27/2018
2, 04/18/2018, 1, 04/18/2017, 04/18/2018
2, 04/10/2018, 1, 04/10/2017, 04/10/2018
;
run;
proc sql;
create table want as
select distinct *, stdt as STDFT format date9., stdt as ENDTFT format date9.
from dates
where cond=1 and date between "stdft."d and "endtft."d;
quit;
What it says. The string
stdft.
is not a valid date in DATE9. format (which is needed for a date literal).
Your variables STDT and ENDT are already valid SAS dates. You don't need to put quotes around them and add D as in "stdft."d. You can just use STDT and ENDT without modification.
proc sql;
create table want as
select distinct *
from dates
where cond=1 and date >= stdt and date <= endt;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.