Using prompts for a month

Reply
Occasional Contributor
Posts: 10

Using prompts for a month

Hi Community,

I really spent a lot of time on this and couldnt figure out a solution. Actually the problem sounds quite simple. My input field PERIOD has been detected has Datetime20. by SAS.

Now I create a Prompt (PROMPTNAME) with Prompt Type: Date; Date Type: Month. Afterwards I insert a filter in the query builder: PERIOD IN A RANGE PROMPTNAME. However my resultset is always empty.

I hope sbd. can help me with this.

Cheers


PROC Star
Posts: 7,366

Re: Using prompts for a month

I'm not at all familiar with the method, but would it work if you declare the prompt type as a timestamp?  take a look at: http://support.sas.com/documentation/cdl/en/wbsvcdg/62759/HTML/default/viewer.htm#n0engedu4ofcwvn1o4...

Occasional Contributor
Posts: 10

Re: Using prompts for a month

Hi,

thanks for your answer unfortunately this is not an option as the user wants to enter a month in a certain year.

Any further ideas why it is not working?

Best regards

Respected Advisor
Posts: 3,908

Re: Using prompts for a month

One way around this would be to not use the Query Builder but to write your own SQL in a Program node.

This would allow you to define the prompt as you did...

Capture.PNG

...and then to assign the prompt to your Program node (under "Properties").

You then can deal with this datetime/date "missmatch" in your code.

Capture.PNG

Occasional Contributor
Posts: 10

Re: Using prompts for a month

Hi!

Thanks a lot for ur reply. This works fine. Is there any chance to use the intck part in an advanced expression filter?

Cheers

Respected Advisor
Posts: 3,908

Re: Using prompts for a month

What I don't know and you would have to try is how to assign a prompt in a Query Builder when using this prompt in an advanced expression. But if this is possible then yes: You can use any SAS function in the advanced expression builder.

O.K - found it!

With the query builder you define an advanced filter like:

intck('month',datepart(t1.period),"&myprompt"d) = 0

Then you define a prompt (here "myprompt")- and done!

Capture.PNG

Occasional Contributor
Posts: 7

Re: Using prompts for a month

Hello everybody,

I've stumbled over the same question as Hagen while testing date prompts in SAS EG 5.1.

While Patrick's solution certainly works fine, I feel like the prompting framework should work especially for less experienced users, who are rather not familiar with macro variables and functions like "datepart".

Is there any way to use the prompting with Date type month (or week, year, quarter...) without complicated workarounds, but rather "as it looks like".

Especially, which operator are these date typ thought to be used with? I tried EQ and BETWEEN but neither of them got me the logical results (namely all records where the input field is between the first and the last day of the specified month / week / year).

With EQ i just got the records of the first day only, BETWEEN gave no results at all.

Thanks in advance,

Ask a Question
Discussion stats
  • 6 replies
  • 492 views
  • 0 likes
  • 4 in conversation