DATA Step, Macro, Functions and more

subsetting in a where clause with a date format

Reply
Occasional Contributor
Posts: 17

subsetting in a where clause with a date format

I'm using a date format:  FORMAT DATE MONYY5.

 

the data appears correctly in the dataset, but whenever I try to subset on that date, I receive an error:

36   PROC SGPLOT DATA = TOT_CLABSI  (WHERE=(DATE < "APR16"d ));
ERROR: Invalid date/time/datetime constant "APR16"d.

 

Please help me figure out what I'm doing wrong1

 

Thank you!

Super User
Posts: 7,866

Re: subsetting in a where clause with a date format

Posted in reply to tmtemples

A SAS date constant must always include days, months and years.

Therefore you need to enter it as '01apr2016'd in this case.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 17

Re: subsetting in a where clause with a date format

Posted in reply to KurtBremser
Thank you! I though I needed to use the same format!
Super User
Posts: 7,866

Re: subsetting in a where clause with a date format

Posted in reply to tmtemples

PS no matter how it is formatted, a SAS date is always a number, counting days from January 1st, 1960.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 225 views
  • 0 likes
  • 2 in conversation