BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CWilson4815
Fluorite | Level 6

Hi guys,

 

I have a computed column I'm using with a query builder in SAS EG 7.1 that takes the amount of days between my field called t2.MODIFIEDDATE and today.

 

It currently reads as follows and works fine:

 

DATDIF( t2.MODIFIEDDATE,DATE(),'ALT/ALT')

 

However, I would like to be able to have today's date replaced with a date that is a variable that can be typed in via prompt so I can "backdate" it to act as if it were to be run yesterday, for example.

 

Do you know how I can go about this?

 

Thanks,

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
6 REPLIES 6
Kurt_Bremser
Super User

In Enterprise Guide, add a User Prompt (icon right next to the server list, blue circle with digits 1,2,3). Define it as a date prompt. In the code, you have access to the result via a macro variable that has the same name as the prompt.

eg if you named your prompt "mydate", your code will then look like

DATDIF( t2.MODIFIEDDATE,&mydate.,'ALT/ALT')
CWilson4815
Fluorite | Level 6

Thanks Kurt, however it is returning the following SYNTAX error:

 

(DATDIF( t2.MODIFIEDDATE,&mydate.,'ALT/ALT')) LABEL="DAYSSINCELASTDECISION" AS DAYSSINCELASTDECISION,

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, ), BTRIM, INPUT, PUT, SUBSTRING, USER. ERROR 22-322: Syntax error, expecting one of the following: a name, *.
CWilson4815
Fluorite | Level 6

Looks like we're nearly there but I've got an error as follows:

 

 

 

((DATDIF( t2.MODIFIEDDATE,"&mydate."d,'ALT/ALT'))) LABEL="DAYSSINCELASTDECISION" AS DAYSSINCELASTDECISION,
WARNING: Apparent symbolic reference MYDATE not resolved.
ERROR: Invalid date/time/datetime constant "&mydate."d.
CWilson4815
Fluorite | Level 6

School boy stuff, thanks a lot Kurt.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 978 views
  • 0 likes
  • 2 in conversation