<?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 derive Last day of last month? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451105#M113668</link>
    <description>&lt;P&gt;Forget the &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/177313"&gt;@Community_Guide&lt;/a&gt; post, I just hit the wrong button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you shall not prompt for a date, then which date should be used?&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 14:05:05 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-04-04T14:05:05Z</dc:date>
    <item>
      <title>How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451102#M113665</link>
      <description>&lt;P&gt;Appreciate if someone of you help me understand the macro variable/function to overwrite&amp;nbsp;&lt;STRONG&gt;&amp;amp;Prompt_Execution_dt.&lt;/STRONG&gt; I was in the process of updating the old programs and when I execute this code in EG it asks for a prompt before it produce the result. However I was asked to not to use this approach now and I'm not certain what can I write in the below program instead of &amp;amp;Prompt_Execution_dt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;34         Data _null_;
35         	FORMAT FirstDayofReportingMonth_dt LastDayofReportingMonth_dt REPORTING_DT DATE9.;
36         	FORMAT REPORTING_DTTM DATETIME23.;
37         
38         	FirstDayofReportingMonth_dt = INTNX ('MONTH', "&amp;amp;Prompt_Execution_dt"d, -1, 'B');
39         	LastDayofReportingMonth_dt = INTNX ('MONTH', "&amp;amp;Prompt_Execution_dt"d, -1, 'E');
40         	call symput("FirstDayofReportingMonth", put (FirstDayofReportingMonth_dt, yymmddn8.));
41         	call symput("LastDayofReportingMonth", put (LastDayofReportingMonth_dt, yymmddn8.));
42         
43         	REPORTING_DT = LastDayofReportingMonth_dt;                                                                                 

44         	REPORTING_DTTM = INPUT (PUT (REPORTING_DT, DATE9.) || ':23:59:59', DATETIME18.);
45         	call symput("reporting_date", put (REPORTING_DT, date9.));
46         	call symput("reporting_datetime", left (put (REPORTING_DTTM, datetime23.)));
47         	call symput("reporting_num_date", put (REPORTING_DT, yymmddn8.));
48         Run;

NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

49         
50         %put FirstDayofReportingMonth = &amp;amp;FirstDayofReportingMonth;
FirstDayofReportingMonth = 20180301
51         %put LastDayofReportingMonth  = &amp;amp;LastDayofReportingMonth;
LastDayofReportingMonth  = 20180331
52         %put reporting_date           = &amp;amp;reporting_date;
reporting_date           = 31MAR2018
53         %put reporting_datetime       = &amp;amp;reporting_datetime;
reporting_datetime       = 31MAR2018:23:59:59
54         %put reporting_num_date       = &amp;amp;reporting_num_date;
reporting_num_date       = 20180331&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451102#M113665</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-04-04T14:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month? [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451103#M113666</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Wed, 04 Apr 2018 14:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451103#M113666</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-04-04T14:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451105#M113668</link>
      <description>&lt;P&gt;Forget the &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/177313"&gt;@Community_Guide&lt;/a&gt; post, I just hit the wrong button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you shall not prompt for a date, then which date should be used?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451105#M113668</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-04T14:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451110#M113672</link>
      <description>&lt;P&gt;Why do you need all that in macro variables?&amp;nbsp; If you know the formula is index(...), then just use that in your code?&amp;nbsp; You seem to be putting a lot of effort into calculating things, then converting to text, then converting back to number to do some more calculations, then saving in text again, none of which seems to give any benefit.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451110#M113672</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-04T14:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451120#M113677</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to give date explicitly in your program instead of using the prompt? Then replace the&amp;nbsp;&lt;STRONG&gt;&amp;amp;Prompt_Execution_dt &lt;/STRONG&gt;with a macro variable&amp;nbsp;that holds date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET Execution_dt=04APR2018;

Data _null_;
FORMAT FirstDayofReportingMonth_dt LastDayofReportingMonth_dt REPORTING_DT DATE9.;
FORMAT REPORTING_DTTM DATETIME23.;
FirstDayofReportingMonth_dt = INTNX ('MONTH', "&amp;amp;Execution_dt"d, -1, 'B');
LastDayofReportingMonth_dt = INTNX ('MONTH', "&amp;amp;Execution_dt"d, -1, 'E');
call symput("FirstDayofReportingMonth", put (FirstDayofReportingMonth_dt, yymmddn8.));
        	call symput("LastDayofReportingMonth", put (LastDayofReportingMonth_dt, yymmddn8.));     
REPORTING_DT = LastDayofReportingMonth_dt;                                                                                 
      	REPORTING_DTTM = INPUT (PUT (REPORTING_DT, DATE9.) || ':23:59:59', DATETIME18.);
call symput("reporting_date", put (REPORTING_DT, date9.));
       	call symput("reporting_datetime", left (put (REPORTING_DTTM, datetime23.)));
        	call symput("reporting_num_date", put (REPORTING_DT, yymmddn8.));
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451120#M113677</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-04T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451124#M113678</link>
      <description>I don't want to hard code anything here. I just want this program to&lt;BR /&gt;automatically take the current date instead of asking for a prompt.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451124#M113678</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-04-04T14:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451126#M113680</link>
      <description>I want this program to use the current date.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Apr 2018 14:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451126#M113680</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-04-04T14:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451161#M113697</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt; wrote:&lt;BR /&gt;I don't want to hard code anything here. I just want this program to&lt;BR /&gt;automatically take the current date instead of asking for a prompt.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In a data step:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   lastmonthend = intnx('month',today(),-1,'E');
   put lastmonthend= mmddyy10.;
run;&lt;/PRE&gt;
&lt;P&gt;However I don't know what you want, or if you even NEED, a macro variable to look like. The example data step should be easy enough to generate a macro variable if needed in the desired form.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing to consider about dates and macro variables: Are people looking at the variable or is it used in calculations internal to the process? Values in formatted date appearance such as "01MAR2018" or "03/01/2018" or "20180301" are more for humans to look at and for actual calculations in SAS data steps or selection filters involving dates then the numeric value, such as LASTMONTHEND above without a format applied is often preferred.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 15:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451161#M113697</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-04T15:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive Last day of last month?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451209#M113718</link>
      <description>&lt;P&gt;Just replace the macro variable with TODAY()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _null_;
FORMAT FirstDayofReportingMonth_dt LastDayofReportingMonth_dt REPORTING_DT DATE9.;
FORMAT REPORTING_DTTM DATETIME23.;
FirstDayofReportingMonth_dt = INTNX ('MONTH', TODAY(), -1, 'B');
LastDayofReportingMonth_dt = INTNX ('MONTH', TODAY(), -1, 'E');
	call symput("FirstDayofReportingMonth", put (FirstDayofReportingMonth_dt, yymmddn8.));
    call symput("LastDayofReportingMonth", put (LastDayofReportingMonth_dt, yymmddn8.));     
REPORTING_DT = LastDayofReportingMonth_dt;                                                                                 
REPORTING_DTTM = INPUT (PUT (REPORTING_DT, DATE9.) || ':23:59:59', DATETIME18.);
	call symput("reporting_date", put (REPORTING_DT, date9.));
    call symput("reporting_datetime", left (put (REPORTING_DTTM, datetime23.)));
    call symput("reporting_num_date", put (REPORTING_DT, yymmddn8.));
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Apr 2018 17:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-derive-Last-day-of-last-month/m-p/451209#M113718</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-04T17:04:09Z</dc:date>
    </item>
  </channel>
</rss>

