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
Kurt_Bremser
Super User

I only see a lot of %let's with text literals and no logic, so there can't be a bug at all.


@tomrvincent wrote:

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;


 

PaigeMiller
Diamond | Level 26

I'm not understanding this example at all.

 

A %let statement allows you to assign any text you want to the macro variable.

ballardw
Super User

Which line do think is calculating a "max date"?

Hint: None of your code does.

 

The macro language is predominately a Text generating program. If you want to use functions, such as related to dates then you would 1) indicate an actual date value and 2) use appropriate functions such as INTNX to increment(decrement) the value which would require in the macro language use of 3) macro function %sysfunc.

Or do the calculation(s) in a data step and then use Call Symputx to assign the value to a macro variable.

 

 

Please see this a brief manipulation of text dates

 %LET Rcv_Date_min_end = 31Mar2018;
 %let dv = %sysfunc(inputn(&Rcv_Date_min_end.,date9.));
 %put numeric value for DV is &dv Using mmddyy format %sysfunc(putn(&dv.,mmddyy10.));
 %put First of month for DV is %sysfunc(putn(%sysfunc(intnx(month,&dv,0,B)),mmddyy10.));

Note use of multiple sysfunc with each function call: INPUTNPUTN and INTNX

 

Reeza
Super User

Macro variables are text. If you take the max/min of text, it does it alphabetically and has nothing to do with the underlying date value. 01April is less than 01March alphabetically, because 01A is before 01M. 

 

 

 

tomrvincent
Rhodochrosite | Level 12

My post shows the output from the log.  Create a month date prompt called Rcv_Date and you'll see that in your log.

 

 

image.png

 

Reeza
Super User

Can you explain exactly what steps you took so we can replicate the issue? Did you set the max/min value for starters? Did you set it to Date or Date Range?  Did you specify any of the options? Show a screenshot of the Prompt Type and Values window with your settings and include your SAS AND EG version. 

tomrvincent
Rhodochrosite | Level 12

Did you create a variable as I show above, run the program and look at your log?  You'll see what I posted.  Nothing fancy about it.

PaigeMiller
Diamond | Level 26

So @tomrvincent, you still have not provided sufficient context for me to understand what you are doing.

 

You show us a screen that has "Edit Prompt" at the top, but I have no idea what screen this is, or how to make it appear. Context is important, and as I said, there is no context here.

Reeza
Super User

I did. The END and the START seem correct to me. I think you're interpreting max/min differently than how SAS is. 

Kurt_Bremser
Super User

When you have a MONTH prompt, the days are irrelevant. That's why the min/max both use the first.