BookmarkSubscribeRSS Feed
luvscandy27
Quartz | Level 8

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;
2 REPLIES 2
PaigeMiller
Diamond | Level 26

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;

 

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 1080 views
  • 0 likes
  • 3 in conversation