<?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: First and last day of previous month in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910266#M44135</link>
    <description>&lt;P&gt;Are you using Enterprise Guide?&amp;nbsp; If so you can create a code block and run it so that the macro variables exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain more completely what you are doing that is prompting you for start and stop datetimes?&amp;nbsp; Can you manually enter values into the prompts and get it to work?&amp;nbsp; What do the values you entered look like?&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2024 14:57:57 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-01-03T14:57:57Z</dc:date>
    <item>
      <title>First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910234#M44124</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a macro variable that I can put in the filter to put my date between the first and last day of the previous month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I want to take a column of some table and in a filter to put that column and between &amp;amp;first_day_previous_month and &amp;amp;last_day_previous_month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tijanagilic_0-1704287712052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92213i1A7023A63F4EA880/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tijanagilic_0-1704287712052.png" alt="tijanagilic_0-1704287712052.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 13:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910234#M44124</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T13:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910242#M44125</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let first_day_previous_month = %sysfunc(intnx(month,%sysfunc(today()),-1,b));
%let last_day_previous_month = %sysfunc(intnx(month,%sysfunc(today()),-1,e));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jan 2024 13:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910242#M44125</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-03T13:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910245#M44126</link>
      <description>What do I put in the filter?&lt;BR /&gt;%first_day_previous_month and %last_day_previous_month ?&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910245#M44126</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T14:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910248#M44127</link>
      <description>&lt;P&gt;Yes. The macro variables contain the raw date value (count of days from 1960-01-01) and can be used in calculations and comparisons.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910248#M44127</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-03T14:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910249#M44128</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443558"&gt;@tijanagilic&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;What do I put in the filter?&lt;BR /&gt;%first_day_previous_month and %last_day_previous_month ?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you have to run the code provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;first, before you can use these variables to filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, in the filter dialog box, you want&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;first_day_previous_month&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;last_day_previous_month&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910249#M44128</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-03T14:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910252#M44129</link>
      <description>I've done it, but it's not giving me data, just an empty table.</description>
      <pubDate>Wed, 03 Jan 2024 14:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910252#M44129</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T14:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910253#M44130</link>
      <description>&lt;P&gt;Is open_date a true SAS date value? Please run PROC CONTENTS on your dataset and show the output for the variable.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910253#M44130</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-03T14:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910260#M44132</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443558"&gt;@tijanagilic&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I've done it, but it's not giving me data, just an empty table.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In addition to the advice from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;to show PROC CONTENTS output on this variable, I suppose it is possible that the correct answer is an empty table. Can you confirm somehow (but searching the table "manually") that there are record(s) that should be selected by this filter?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910260#M44132</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-03T14:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910265#M44134</link>
      <description>I have around 8.000 rows when i do it 'manually'.&lt;BR /&gt;&lt;BR /&gt;OPEN_DATE is format 20DEC2002:00:00:00&lt;BR /&gt;&lt;BR /&gt;I am not sure what to do with:&lt;BR /&gt;Please run PROC CONTENTS on your dataset and show the output for the variable.&lt;BR /&gt;&lt;BR /&gt;I'm new to this, so if you can be more specific, I'd appreciate it.</description>
      <pubDate>Wed, 03 Jan 2024 14:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910265#M44134</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T14:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910266#M44135</link>
      <description>&lt;P&gt;Are you using Enterprise Guide?&amp;nbsp; If so you can create a code block and run it so that the macro variables exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you explain more completely what you are doing that is prompting you for start and stop datetimes?&amp;nbsp; Can you manually enter values into the prompts and get it to work?&amp;nbsp; What do the values you entered look like?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 14:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910266#M44135</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-03T14:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910270#M44137</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;OPEN_DATE is format 20DEC2002:00:00:00&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is the key piece of information that was missing. Your variable OPEN_DATE is not a DATE at all (I work with databases with the same problem). It is a date/time value, and so the macro variables created must contain date/time values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let first_day_previous_month = %sysfunc(intnx(dtmonth,%sysfunc(datetime()),-1,b));
%let last_day_previous_month = %sysfunc(intnx(dtmonth,%sysfunc(datetime()),-1,e));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 15:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910270#M44137</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-03T15:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910271#M44138</link>
      <description>I am using Enterprise Guide.&lt;BR /&gt;&lt;BR /&gt;I have many tables, which contain columns of dates, the format I have specified in answer before.&lt;BR /&gt;&lt;BR /&gt;When I manually want to extract data from a table, which is from a certain period, Then I make a new query, drag the columns of data that I need, and in the filter I put a column containing the date (eg open_date) between and write 12/1/23 and 12/31/23. Or another option is to write '1Dec2023:0:0:0'dt and '1Dec2023:0:0:0'dt...&lt;BR /&gt;&lt;BR /&gt;As I need it to refresh monthly, I don't want to manually change those dates every time, but I want to put this between &amp;amp;first_day_month_previous and &amp;amp;last_day_month_previous, so that when I start the project, it refreshes everywhere and contains data from the previous month.&lt;BR /&gt;&lt;BR /&gt;I hope it's understandable now. Sorry if it was not understandable so far.</description>
      <pubDate>Wed, 03 Jan 2024 15:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910271#M44138</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T15:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910273#M44139</link>
      <description>It worked!&lt;BR /&gt;&lt;BR /&gt;Thank you all very much!</description>
      <pubDate>Wed, 03 Jan 2024 15:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910273#M44139</guid>
      <dc:creator>tijanagilic</dc:creator>
      <dc:date>2024-01-03T15:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910279#M44140</link>
      <description>&lt;P&gt;You need to know your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do any of the values in the dataset have non zero time of day parts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that&amp;nbsp;'31DEC2023:08:00:00'dt is greater than '31DEC2023:00:00:00'dt so filtering on values between '01DEC2023:00:00:00'dt and '31DEC2023:00:00:00t'dt will miss most of the values on the last day of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 15:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910279#M44140</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-03T15:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: First and last day of previous month</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910299#M44144</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You need to know your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do any of the values in the dataset have non zero time of day parts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that&amp;nbsp;'31DEC2023:08:00:00'dt is greater than '31DEC2023:00:00:00'dt so filtering on values between '01DEC2023:00:00:00'dt and '31DEC2023:00:00:00t'dt will miss most of the values on the last day of the month.&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;For the above solution, I point out that the value of &amp;amp;last_day_of_previous_month is&amp;nbsp;2019686399 which turns out to be&amp;nbsp;31DEC2023:23:59:59 (if run on 03JAN2024, so this handles the case you mention.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 17:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/First-and-last-day-of-previous-month/m-p/910299#M44144</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-03T17:35:51Z</dc:date>
    </item>
  </channel>
</rss>

