<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: EG (Date Formula) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464976#M30081</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20776i0880F66747A1474E/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.png" alt="SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hi Partick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can i copy &amp;amp; past into the table titles as shown above ? I&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try to run it, but it doesn't seem work. Am&amp;nbsp;i miss out something ?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 May 2018 07:56:00 GMT</pubDate>
    <dc:creator>SASnewbie2</dc:creator>
    <dc:date>2018-05-25T07:56:00Z</dc:date>
    <item>
      <title>EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464957#M30070</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your advice&amp;nbsp;what function or formula should i input if i would like to get a&amp;nbsp;yesterday date in EG to show in the Table Title&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In excel formula is&amp;nbsp; (Today()-1), how about in SAS ? i have tried this&amp;nbsp;%sysfunc(today()-1, ddmmyy10) but it doesn't work&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 06:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464957#M30070</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T06:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464958#M30071</link>
      <description>&lt;P&gt;It's the same, literally:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
format date yymmddd10.;
date = today();
put date=;
date = today() - 1;
put date=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;27         data _null_;
28         format date yymmddd10.;
29         date = today();
30         put date=;
31         date = today() - 1;
32         put date=;
33         run;

date=2018-05-25
date=2018-05-24
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 06:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464958#M30071</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-25T06:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464960#M30072</link>
      <description>&lt;P&gt;Hi Kurtbremser,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your advice. However, I would like to have the yesterday date in the Table title.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate you could advise how should i revise the formula below .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales Revenue&amp;nbsp;as at %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) to become Sales Revenue as at 24.05.2018 (One day before)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 06:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464960#M30072</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T06:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464961#M30073</link>
      <description>&lt;P&gt;When I need to more that a simple assignment, I use to create macro variables in a data step for easier readable code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
call symput('yesterday',trim(put(today()-1,nldate20.)));
run;

title "SASHELP.CLASS at &amp;amp;yesterday";

proc print data=sashelp.class;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which results in&lt;/P&gt;
&lt;PRE&gt;         SASHELP.CLASS at 24. Mai 2018          

Obs    Name       Sex    Age    Height    Weight

  1    Alfred      M      14     69.0      112.5
  2    Alice       F      13     56.5       84.0
  3    Barbara     F      13     65.3       98.0
  4    Carol       F      14     62.8      102.5
  5    Henry       M      14     63.5      102.5
  6    James       M      12     57.3       83.0
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 07:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464961#M30073</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-25T07:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464970#M30078</link>
      <description>&lt;P&gt;Hi Kurtbremser,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can i modify from formula below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%TRIM(%QSYSFUNC(DATE(), NLDATE20.)) to yesterday date&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 07:33:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464970#M30078</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T07:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464973#M30079</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200077"&gt;@SASnewbie2&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You can using spaghetti code&lt;/P&gt;
&lt;PRE&gt;%put %sysfunc(sum(%sysfunc(today()),-1), nldate20. -l);&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 07:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464973#M30079</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-25T07:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464976#M30081</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20776i0880F66747A1474E/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.png" alt="SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Hi Partick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can i copy &amp;amp; past into the table titles as shown above ? I&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try to run it, but it doesn't seem work. Am&amp;nbsp;i miss out something ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 07:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464976#M30081</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T07:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464979#M30083</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200077"&gt;@SASnewbie2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20776i0880F66747A1474E/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS.png" alt="SAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hi Partick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can i copy &amp;amp; past into the table titles as shown above ? I&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try to run it, but it doesn't seem work. Am&amp;nbsp;i miss out something ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the %PUT statement. Below the bit which you need to pass in for your title&lt;/P&gt;
&lt;PRE&gt;%sysfunc(sum(%sysfunc(today()),-1), nldate20. -l)&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 08:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464979#M30083</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-25T08:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464980#M30084</link>
      <description>&lt;P&gt;Oh, you need it for pointy-clicky.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put is a macro statement that writes to the log; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; just used it so you could see the result.&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%trim(%sysfunc(sum(%sysfunc(today()),-1), nldate20.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in your title bar.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 08:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464980#M30084</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-25T08:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464981#M30085</link>
      <description>&lt;P&gt;Hi Patrick &amp;amp; KurtBremser,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works now, thanks a lots for your advice &amp;amp; assistance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would you mind to explain why need to include the Sum( function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;today&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; nldate20&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 08:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464981#M30085</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T08:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464987#M30089</link>
      <description>&lt;P&gt;When working with the macro facility, always keep in mind it is a preprocessor for creating programs, and it only knows the datatype text, and by itself is incapable of doing calculations.&lt;/P&gt;
&lt;PRE&gt;today() - 1&lt;/PRE&gt;
&lt;P&gt;is just text for it, and %sysfunc accepts as its first argument only a single data step function call; the additional %sysfunc(sum()) takes care of the calculation, which would not be possible otherwise.&lt;/P&gt;
&lt;P&gt;An alternative is the use of %eval, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%trim(%sysfunc(putn(%eval(%sysfunc(today())-1), nldate20.)))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My personal preference is to never use more than one %sysfunc in one line, as you can see how it tends to clutter up the code and make it harder to see the logic behind the code. Therefore my preferred method to unload such calculations into a preceding data step.&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 08:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464987#M30089</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-25T08:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464992#M30090</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200077"&gt;@SASnewbie2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Patrick &amp;amp; KurtBremser,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works now, thanks a lots for your advice &amp;amp; assistance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would you mind to explain why need to include the Sum( function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token macrostatement"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;today&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; nldate20&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You've got already all the explanation from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; but to say it in other words:&lt;/P&gt;
&lt;P&gt;%sysfunc() allows you to use a single SAS data step function on SAS macro level.&lt;/P&gt;
&lt;P&gt;We need to do two things: Call the today() function and substract a value from another value. So we need two %sysfunc() AND we need to use also a SAS function&amp;nbsp; - SUM() - for this substraction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option would have been to use the SAS calendar function INTNX() instead of SUM() to shift the SAS date value. Something like:&lt;/P&gt;
&lt;PRE&gt;%sysfunc(intnx(day,%sysfunc(today()),-1), nldate20. -l)&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 May 2018 08:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464992#M30090</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-25T08:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: EG (Date Formula)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464995#M30091</link>
      <description>&lt;P&gt;Hi Both,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lots for your advice &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2018 09:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Date-Formula/m-p/464995#M30091</guid>
      <dc:creator>SASnewbie2</dc:creator>
      <dc:date>2018-05-25T09:01:55Z</dc:date>
    </item>
  </channel>
</rss>

