BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhca60
Quartz | Level 8
I have a program I’m working on explaining to a client. What does
Days_total=SUM(“rpt_run_dt.”d, -date); mean?
Does it mean total number of days between report run date and date? What does the minus sign in front of date mean?
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

The SUM function adds two (or more) values

 

In this case, it adds the value of this date

 

"&rpt_run_dt."d

 

and the negative of the value of variable DATE. Essentially this is a subtraction, but because it is in the SUM function, a missing is treated as zero and then the SUM function does not return a missing if one of the values is missing.

 

By the way, those "curly" quotes in your code snippet will cause an error and should never be used. Use "straight" quotes as I did above.

 

By the way, I assume that rpt_run_dt is a macro variable even though you didn't use the & because if not, then this won't work either, the period immediately after rpt_run_dt will cause an error if it is not a macro variable. 

 

Please type carefully!

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

The SUM function adds two (or more) values

 

In this case, it adds the value of this date

 

"&rpt_run_dt."d

 

and the negative of the value of variable DATE. Essentially this is a subtraction, but because it is in the SUM function, a missing is treated as zero and then the SUM function does not return a missing if one of the values is missing.

 

By the way, those "curly" quotes in your code snippet will cause an error and should never be used. Use "straight" quotes as I did above.

 

By the way, I assume that rpt_run_dt is a macro variable even though you didn't use the & because if not, then this won't work either, the period immediately after rpt_run_dt will cause an error if it is not a macro variable. 

 

Please type carefully!

--
Paige Miller
bhca60
Quartz | Level 8
Yes it’s a macro. Thank you. Yes I had to type this since I didn’t want to use my work computer that’s why the quotes look like that and I forgot the ampersand.
PaigeMiller
Diamond | Level 26

@bhca60 wrote:
Yes it’s a macro. Thank you. Yes I had to type this since I didn’t want to use my work computer that’s why the quotes look like that and I forgot the ampersand.

No, it's not a macro. It is a macro variable. Macros and macro variables are different things. Do not say macro variables are "a macro". Clear communication avoids confusion! 

 

Typing here in the SAS forums will not produce curly quotes. See --> """""""

 

Typing in a word processor or something like PowerPoint produces the curly quotes. Don't use word processors or PowerPoint for typing SAS code.

--
Paige Miller