<?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: defining the first and last day of the month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776381#M246912</link>
    <description>&lt;P&gt;SAS date values are counts of days with 1960-01-01 as day zero. For comparisons, formats are irrelevant, so you best store raw, unformatted values in macro variables (see Maxim 28).&lt;/P&gt;
&lt;P&gt;To get first and last day of the current month, use INTNX:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let first_day = %sysfunc(intnx(month,%sysfunc(today()),0,b));
%let last_day = %sysfunc(intnx(month,%sysfunc(today()),0,e));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Oct 2021 07:17:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-26T07:17:51Z</dc:date>
    <item>
      <title>defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776379#M246910</link>
      <description>&lt;P&gt;I have a question for you. Is there a chance to create a macro something similar to this, but in prco sql in quera where it always selects the first day and the last of the month&lt;/P&gt;&lt;PRE&gt;%let thismonth=%sysfunc(putn(%sysfunc(today()),yymmn6.));&lt;/PRE&gt;&lt;PRE&gt;	where t1.DATE = &amp;amp;thismonth
		and _dly.  between t2.data_from and t2.data_to 
		and &amp;amp;gv_date_dly.  between t3.data_from and t3.data_to 
		and t3.obj_code not in ('G07','N06','N07') &lt;/PRE&gt;&lt;P&gt;where we have date from to be recalled from the 1st day of the month and date_to to the last day of the month when the function &amp;amp; thismonth was called&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 06:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776379#M246910</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T06:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776380#M246911</link>
      <description>And my date format its 2021-10-26</description>
      <pubDate>Tue, 26 Oct 2021 07:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776380#M246911</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T07:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776381#M246912</link>
      <description>&lt;P&gt;SAS date values are counts of days with 1960-01-01 as day zero. For comparisons, formats are irrelevant, so you best store raw, unformatted values in macro variables (see Maxim 28).&lt;/P&gt;
&lt;P&gt;To get first and last day of the current month, use INTNX:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let first_day = %sysfunc(intnx(month,%sysfunc(today()),0,b));
%let last_day = %sysfunc(intnx(month,%sysfunc(today()),0,e));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 07:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776381#M246912</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-26T07:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776387#M246917</link>
      <description>&lt;P&gt;Thanks Kurt ! One question i hope, should I change my code for below. &lt;STRONG&gt;because I run the code it shows me neither errors nor results&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;where t1.DATA_DANYCH between &amp;amp;first_day and &amp;amp;last_day and t2.data_od = &amp;amp;first_day and t2.data_do = &amp;amp;last_day and t3.data_od = &amp;amp;first_day and t3.data_do = &amp;amp;last_day&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 07:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776387#M246917</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T07:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776390#M246919</link>
      <description>&lt;P&gt;Maxim 3: Know Your Data.&lt;/P&gt;
&lt;P&gt;Run PROC CONTENTS to make sure your variables contain SAS dates (numeric with date format assigned).&lt;/P&gt;
&lt;P&gt;Then inspect the values to see what is present. PROC FREQ can be useful for dates (I use it every time I need to get a picture of stored date values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that does not provide a clue, show us values for your dates where the condition does not work as expected.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 07:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776390#M246919</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-26T07:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776394#M246921</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/401093"&gt;@Gieorgie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Kurt ! One question i hope, should I change my code for below. &lt;STRONG&gt;because I run the code it shows me neither errors nor results&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;where t1.DATA_DANYCH between &amp;amp;first_day and &amp;amp;last_day and t2.data_od = &amp;amp;first_day and t2.data_do = &amp;amp;last_day and t3.data_od = &amp;amp;first_day and t3.data_do = &amp;amp;last_day&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;May need to share some actual values for the variables along with the entire Proc SQL code.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 08:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776394#M246921</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-26T08:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776396#M246922</link>
      <description>&lt;PRE&gt;proc sql;

	create table PolisyEnd as 

	select
	t1.obj_oid
	,t1.PRP_AGREEMENT				 
	,t1.PRP_POLICYNUMBER
	,t1.PRP_SOCIETY_PID
	,t1.PRP_END_DATE 				as PRP_END_DATE
	from 
		cmz.WMDTZDP_BH t1 ,
		where t1.data_od = &amp;amp;first_day. 
        and t1.data_do = &amp;amp;gv_date_dly.
left join 
		(select kontr_id,obj_oid from cmz.BH_D_ZAB_X_ALOK_&amp;amp;thismonth where data_danych = &amp;amp;gv_date_dly.) t2 on t2.obj_oid = t1.obj_oid ;

quit;&lt;BR /&gt;&lt;BR /&gt;%let gv_date_dly=%sysevalf(%bquote('&amp;amp;date_dly.'d));&lt;BR /&gt;%let thismonth=%sysfunc(putn(%sysfunc(today()),yymmn10.));&lt;BR /&gt;%let first_day = %sysfunc(intnx(month,%sysfunc(today()),0,b));&lt;BR /&gt;%let last_day = %sysfunc(intnx(month,%sysfunc(today()),0,e));&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_0-1635236700071.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65027i3038436B0AA2D7DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_0-1635236700071.png" alt="Gieorgie_0-1635236700071.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now i got error "ERROR 22-322:Syntax error, one of the following was expected:;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, EQT, "&amp;nbsp; here : where t1.data_od = &amp;amp;first_day. and t1.data_do = &amp;amp;gv_date_dly.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 08:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776396#M246922</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T08:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776398#M246923</link>
      <description>Hi, I changed my code and you have example on above</description>
      <pubDate>Tue, 26 Oct 2021 08:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776398#M246923</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-26T08:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: defining the first and last day of the month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776412#M246929</link>
      <description>&lt;P&gt;You have an invalid comma in the FROM clause, and you must move the WHERE clause after the JOIN, which is part of the FROM.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;from 
  cmz.WMDTZDP_BH t1
left join 
  (select kontr_id,obj_oid from cmz.BH_D_ZAB_X_ALOK_&amp;amp;thismonth where data_danych = &amp;amp;gv_date_dly.) t2
on t2.obj_oid = t1.obj_oid
where t1.data_od = &amp;amp;first_day. and t1.data_do = &amp;amp;gv_date_dly.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 09:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/defining-the-first-and-last-day-of-the-month/m-p/776412#M246929</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-26T09:48:13Z</dc:date>
    </item>
  </channel>
</rss>

