BookmarkSubscribeRSS Feed
0 Likes

Editor's note: this suggestion relates to the SAS code that is generated when you create a date prompt in SAS Enterprise Guide (project prompts or SAS stored processes).

 

I think it's a bug, but SAS may consider it a 'feature'...but when you specify a date as a month, you get this:

 

16         %LET Rcv_Date_min_end = 31Mar2018;
17         %LET Rcv_Date_max_end = 31Mar2018;
18         %LET Rcv_Date_min_label = Previous month;
19         %LET Rcv_Date_max_rel = M-1M;
20         %LET Rcv_Date_min = 01Mar2018;
21         %LET Rcv_Date_max = 01Mar2018;
22         %LET Rcv_Date_max_label = Previous month;
23         %LET Rcv_Date_min_rel = M-1M;

 

So why is the max date the same as the first of the month?  uh...no.  Line 21 should be this:

 

21         %LET Rcv_Date_max = 31Mar2018;

31 Comments
tomrvincent
Rhodochrosite | Level 12

okay @PaigeMiller...looks like you've never created a month date prompt variable before. 

 

Here's how to do it.

 

In your program, click on 'properties'.

Go to 'prompts'.

Click on 'prompt manager' button.

click on 'add' button.

create a new variable named rcv_date as below:

image.png

 

click on 'prompt type and values' tab.  Fill it out like this:

image.png

 

run your program and look at the log.  A bunch of new macro variables are created.  Here's the log for 'foodate':

 

10         %LET foodate_min = 01Mar2018;
11         %LET foodate_min_end = 31Mar2018;
12         %LET foodate_min_rel = M-1M;
13         %LET foodate_max_rel = M-1M;
14         %LET foodate_max_end = 31Mar2018;
15         %LET foodate_max = 01Mar2018;
16         %LET foodate_min_label = Previous month;
17         %LET foodate_max_label = Previous month;

 

See how foodate_max is the beginning of the month?  Do you see something different?

tomrvincent
Rhodochrosite | Level 12

@ballardw that's not code...it's a log.  Code doesn't have line numbers.

PaigeMiller
Diamond | Level 26

Still not enough context.

 

"In your program"


What program? I am using SAS 9.4TS1M4 (sometimes called Base SAS), and there is no "prompts". What program are you using?

tomrvincent
Rhodochrosite | Level 12

@PaigeMiller this is SAS EG.  That's why it's tagged

PaigeMiller
Diamond | Level 26

I never read the tags. I read what people write. If there's key information that's only contained in the tags, I guess I have a problem with that.

tomrvincent
Rhodochrosite | Level 12

@PaigeMiller Yep.  And I selected the tag, so that would count as something I wrote.  In fact, you can't even post an idea without selecting one or more tags.

ballardw
Super User

I am still not sure which "max date" is actually incorrect and for what purpose it is incorrect. As I understand what you are a doing in the prompt setting is setting a limit on a drop down list or which values may be entered.

 

With

14         %LET foodate_max_end = 31Mar2018;
15         %LET foodate_max = 01Mar2018;
16         %LET foodate_min_label = Previous month;
17         %LET foodate_max_label = Previous month;

 

See how foodate_max is the beginning of the month?  Do you see something different?

And do you see foodate_max_end, which is the end of the month? These are settings for the min and max objects. Since you have "Previous month" in both the From and To objects those are the minimum and maximum values of the RANGES for the start and end or your "date range" prompt type. From the documentation for date range prompt:

 

A date range prompt contains two dates that are the upper and lower boundaries for a range of dates. 

So that looks like the user is expected to enter a start and end date such as 03Mar2018 15Mar2018. And the Prompt manager maintains a list of minimum and maximum values for the earliest date (min) and the latest date (max) that you can enter in both the beginning of the range and the end of the range.

 

 

Are you intending to enter a range or a single value that should be within the range of the previous month? If the later then you likely want a DATE type not Date Range.

tomrvincent
Rhodochrosite | Level 12

@ballardwof course I see it.  I posted it.  The initial problem is that a date type (and a day type of date range) doesn't have 'beginning of previous month' and 'end of previous month'...only date range with a date type of month does.

 

How many reports are run for the previous month?  That's why I changed my program to use date month type. 

But I still think that 'foodate_max' is wrong.

Reeza
Super User

@tomrvincent I think your assumption is that max/min correspond to the max/min of the date range. I don't think that's what SAS is creating. 

Run it for two months (2 previous months) and see if that helps you understand what it's doing instead. I don't 'agree/disagree' with what's happening, just that they're different.

Reeza
Super User

And something like this should probably be a question, not a suggestion for a change.  It's not even clear in your post how it's wrong, and what you expect versus what's happening, and how to recreate the issue to see your results. Yes, I can probably figure it out, but it helps to be clear from the start, especially if you're asking SAS to change something.