<?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: How to create a dynamic macro variable which takes yesterday's date? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736918#M229689</link>
    <description>&lt;P&gt;Interval WEEKDAY&amp;lt;weekend days&amp;gt;W allows you to do this (with SAS the week starts Sunday so it's&amp;nbsp;WEEKDAY17W). Documentation &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0pxq4af0hx60nn1i1x3xn41mc3c.htm#n0zn1re74n6pfvn170g9us41coho" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('dt',put(intnx('WEEKDAY17W',today(),-1),date9.));
  stop;
run;

%put &amp;amp;=dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Run above today on Monday April 26.&lt;/P&gt;
&lt;PRE&gt;33         %put &amp;amp;=dt;
DT=23APR2021&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Apr 2021 07:13:46 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-04-26T07:13:46Z</dc:date>
    <item>
      <title>How to create a dynamic macro variable which takes yesterday's date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736911#M229683</link>
      <description>&lt;P&gt;I want to create a macro variable which takes the date of the day before, and hence, its value changes each day. I am using the following code:&lt;/P&gt;
&lt;P&gt;call symputx('PREVIOUS_DATE' , put(intnx('day', today(), -1, 's'), date9.));&lt;/P&gt;
&lt;P&gt;But the problem is that if yesterday was a Sunday, then I would require the macro to take the date of the day before yesterday. For example today id 26APR2021, and yesterday 25APR2021 was a sunday, so I want this macro to take value 24APR2021.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to automate this using an if clause or anything else?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 06:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736911#M229683</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-04-26T06:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dynamic macro variable which takes yesterday's date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736915#M229686</link>
      <description>&lt;P&gt;If you simply want to get the previous day if it is Sunday, you can use the WEEKDAY function.&lt;BR /&gt;If you need to take holidays into concern, please refer to the &lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/lefunctionsref/p12v9lpx7rlthin1cnpd320l3mj3.htm" target="_self"&gt;HOLIDAY function&lt;/A&gt;.(Only common holidays in the U.S. and Canada.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  dt=intnx('day', today(), -1, 's');
  wk=weekday(dt);
  if wk=1 then dt=dt-1;
  call symputx('PREVIOUS_DATE' , put(dt, date9.));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Apr 2021 06:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736915#M229686</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-26T06:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dynamic macro variable which takes yesterday's date?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736918#M229689</link>
      <description>&lt;P&gt;Interval WEEKDAY&amp;lt;weekend days&amp;gt;W allows you to do this (with SAS the week starts Sunday so it's&amp;nbsp;WEEKDAY17W). Documentation &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/leforinforref/n0pxq4af0hx60nn1i1x3xn41mc3c.htm#n0zn1re74n6pfvn170g9us41coho" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('dt',put(intnx('WEEKDAY17W',today(),-1),date9.));
  stop;
run;

%put &amp;amp;=dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Run above today on Monday April 26.&lt;/P&gt;
&lt;PRE&gt;33         %put &amp;amp;=dt;
DT=23APR2021&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 07:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-dynamic-macro-variable-which-takes-yesterday-s/m-p/736918#M229689</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-26T07:13:46Z</dc:date>
    </item>
  </channel>
</rss>

