<?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: SAS changing today() to previous month and subsequent in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379413#M276915</link>
    <description>&lt;P&gt;The whole situation is not very clear to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope one of the two codes can help you:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    td = today();&lt;BR /&gt;    /* -1- */
    end_last_manth = td - day(td);

    /* -2- */
    end_last_month = intbx('month',td,-1,'e');

  call symput('date2', put(end_last_month, ...desired format ...);
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 26 Jul 2017 14:45:35 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-07-26T14:45:35Z</dc:date>
    <item>
      <title>SAS changing today() to previous month and subsequent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379402#M276914</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a program where I have automated dates till reporting month. Reporting month is one month prior to the current month. Suppose current month is July&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; i=1&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%to &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;amp;month&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; ;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%let&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; date2=&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%&lt;SPAN class="currentHitHighlight"&gt;sysfunc&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;(intnx(month, &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%&lt;SPAN class="highlight"&gt;sysfunc&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;(today()),-&amp;amp;i.,e), date9.);"&amp;amp;date2"n &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%end&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;month macro variable&amp;nbsp;i have declared till previous month which is coming 6&amp;nbsp;and used the do loop which is fetching me right results from jan to june this year. &amp;nbsp;The issue is in certain case if the user wants to have reporting month as May or april, how do I do that? this macro variable and macro&amp;nbsp;is used at more than 100 places i can't go and change this everytime...I need some function or macro variable where it should take today() as previous month date or 2 months date prior to current month ... is it possible to define today() to previous month in macro variable.. That will solve my concern.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 14:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379402#M276914</guid>
      <dc:creator>sameer112217</dc:creator>
      <dc:date>2017-07-26T14:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS changing today() to previous month and subsequent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379413#M276915</link>
      <description>&lt;P&gt;The whole situation is not very clear to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope one of the two codes can help you:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    td = today();&lt;BR /&gt;    /* -1- */
    end_last_manth = td - day(td);

    /* -2- */
    end_last_month = intbx('month',td,-1,'e');

  call symput('date2', put(end_last_month, ...desired format ...);
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jul 2017 14:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379413#M276915</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-26T14:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS changing today() to previous month and subsequent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379415#M276916</link>
      <description>&lt;P&gt;Today() cannot be changed - otherwise it would become useless. &amp;nbsp;If you need a bit of text which is the month before today(), then set a macro varible with the information and use that throughout your code - this is the purpose of macro variables.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 14:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379415#M276916</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-26T14:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS changing today() to previous month and subsequent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379423#M276917</link>
      <description>&lt;P&gt;It looks like you count backwards from month to the beginning of the year.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try reversing that loop count so that you can start at the beginning of the period and count forward,&amp;nbsp;it shouldn't require any other changes in your code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=&amp;amp;month %to 1 %by -1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jul 2017 15:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379423#M276917</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-26T15:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS changing today() to previous month and subsequent</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379432#M276918</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89720"&gt;@sameer112217&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone please help me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created a program where I have automated dates till reporting month. Reporting month is one month prior to the current month. Suppose current month is July&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have used&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;%do&lt;/FONT&gt;&lt;/SPAN&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; i=1&lt;/SPAN&gt;&lt;/FONT&gt; &lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%to &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;amp;month&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; ;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%let&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt; date2=&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%&lt;SPAN class="currentHitHighlight"&gt;sysfunc&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;(intnx(month, &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%&lt;SPAN class="highlight"&gt;sysfunc&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;(today()),-&amp;amp;i.,e), date9.);"&amp;amp;date2"n &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="blue" face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;%end&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="1"&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;month macro variable&amp;nbsp;i have declared till previous month which is coming 6&amp;nbsp;and used the do loop which is fetching me right results from jan to june this year. &amp;nbsp;The issue is in certain case if the user wants to have reporting month as May or april, how do I do that? &lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;this macro variable and macro&amp;nbsp;is used at more than 100 places i can't go and change this everytime&lt;/STRONG&gt;&lt;/FONT&gt;...I need some function or macro variable where it should take today() as previous month date or 2 months date prior to current month ... is it possible to define today() to previous month in macro variable.. That will solve my concern.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which macro variable? Month? Date2? Something else?&lt;/P&gt;
&lt;P&gt;Are the "100 places" in one macro? many macros?&lt;/P&gt;
&lt;P&gt;And I can't say that I have ever been happy with variables with names like "31JAN2017"n at that is usually and indication of poor data structure to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might consider adding a keyword parameter to your macro calls that would conditionally override which ever bit of code you are concerned with and set the value of the date(?) variable.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 15:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-changing-today-to-previous-month-and-subsequent/m-p/379432#M276918</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-26T15:28:19Z</dc:date>
    </item>
  </channel>
</rss>

