BookmarkSubscribeRSS Feed
psarathy
SAS Employee


hello after creating a new computed column based on the advice of the earlier discussion

case  when ( t1.date <=  "start_date_90"d then 1  else 0 end

I get a invalid date/time/datetime constat "start_date_90"d.

when i use the prompt in a filter statement the code reflects no error.

what is happening.  am I missing something?

3 REPLIES 3
Reeza
Super User

What is start_date_90? A variable or prompt?

If it's a prompt in date time format use it as &start_date_90 - no quotes and no d.

If it's a variable use start_date_90 - no quotes, no d.

Quotes and D are for when you're hard coding a date comparison.

Tom
Super User Tom
Super User

If the prompt has become a macro variable then use & before the name to resolve the name to the value.

   &START_DATE_90

If it contains a datetime value in text format ( 21JUL2015:13:02 for example) then you can wrap it in quotes and append DT to let SAS know that you want it treated as a datetime literal.

  "&START_DATE_90"DT

If it contains the number of seconds since 01JAN1960 then do not wrap it in quotes as it will be a number.

If you are comparing the value to variables that contain dates then you might need to convert it from datetime to date.

DATEPART("&START_DATE_90"DT)

psarathy
SAS Employee

thanks Tom and Reeza,

apologies... I did use the "&promptvar"dt   the datetime variable is a sas datetime.  so I was hoping the " " and dt would do the trick.. Is this case sensitive?

Ok I tried all the suggestions. I think that using DT instead of D was the game changer.

"&start_date_90"DT  <+ t1.datvar

thanks a lot! it is running !

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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