Desktop productivity for business analysts and programmers

Invalid date/time/datetime constant using prompt

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Invalid date/time/datetime constant using prompt

[ Edited ]

Hey folks. I joined this board specifically because of this issue. I can't a get query to resolve referencing a date prompt using "&EndMonthDate"d. I'm getting the following error:

sas error.PNG

 Any help would be greatly appreciated!


Accepted Solutions
Solution
3 weeks ago
Super User
Super User
Posts: 9,211

Re: Invalid date/time/datetime constant using prompt

You can create macro variables in many ways, the simplest of which is:

%let <macrovariable>=<some text>;

But anyway, you have created a prompt within the code you are working with, or made the prompt response available to your code, and you are sure its called EndMonthDate?  All I have to go on is the warning, and that is clearly stating that does not exist, so either its not called that, or not available in the session you are running the given code.  

View solution in original post


All Replies
Super User
Super User
Posts: 9,211

Re: Invalid date/time/datetime constant using prompt

The warning is telling you that in that SAS session there is no macro variable called EndMonthDate.  Not sure what else we can say other than check where it is being created, maybe you missed a %let statement, or something else is not included or setup??

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

Forgive my novice, but how else do you create a macro variable? Is a prompt sufficient? Because it has been created and is in use throughout other parts of the project.

Solution
3 weeks ago
Super User
Super User
Posts: 9,211

Re: Invalid date/time/datetime constant using prompt

You can create macro variables in many ways, the simplest of which is:

%let <macrovariable>=<some text>;

But anyway, you have created a prompt within the code you are working with, or made the prompt response available to your code, and you are sure its called EndMonthDate?  All I have to go on is the warning, and that is clearly stating that does not exist, so either its not called that, or not available in the session you are running the given code.  

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

Here's an image of my prompt window:

pompt pic.PNG

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

I figured it out with your advice. In the query window you go to Options >> Options for this Query >> Prompts. I added the prompts there and it resolved. Thanks!

Super User
Posts: 13,063

Re: Invalid date/time/datetime constant using prompt

What value was actually entered for the prompt? Was something actually entered or selected for the propmpt?

Your code implies that the value entered should be a date. The prompt would have to be of the form ddmonyy or ddmonyyyy such as

05May2018 or 5May18. No spaces, no other format like 5/5/2018, no punctuation.

 

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

It's a GUI created prompt. I don't have the option of choosing a date format. So I assume SAS EG is selecting the appropriate formatting:

date prompt pic.PNG

PROC Star
Posts: 1,265

Re: Invalid date/time/datetime constant using prompt

Did you right-click on your program, select Properties > Prompts, and add your prompt to be used by the program?

 

Tom

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

It's in a query query pic.PNGnot a programprogram pic.PNG I've written programs but I'm no expert. I don't see where I can add a prompt to a query. Please advise...

PROC Star
Posts: 1,265

Re: Invalid date/time/datetime constant using prompt

Same solution. Save your query, even though it's displaying an error message, then right-click on it, Properties > Prompts, and pick your prompt. I just tried it, it worked fine.

Occasional Contributor
Posts: 8

Re: Invalid date/time/datetime constant using prompt

Thanks it resolved following a similar solution from 'Options' in the query window

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 159 views
  • 0 likes
  • 4 in conversation