<?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 get the last day of the month using %sysfunc and intnx function in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979134#M46282</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No it seems that I need the single quote with a snowflake sql query. But it is a way to thanks that person for giving me the major part of the solution.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Okay that's a good thing to do, but it would be even better if you explained to us why it was marked correct, without us having to ask.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Nov 2025 15:46:16 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-11-19T15:46:16Z</dc:date>
    <item>
      <title>how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979073#M46270</link>
      <description>&lt;P&gt;I would like to get this macro variable calculatedDate equal to : '2025-09-30' and between single quote&lt;/P&gt;
&lt;P&gt;Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let calculatedDate = %sysfunc(INTNX("MONTH", MDY(&amp;amp;mm., 1, &amp;amp;yyyy.), 1)-1);
%put &amp;amp;=calculatedDate;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Nov 2025 22:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979073#M46270</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-11-18T22:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979074#M46271</link>
      <description>&lt;P&gt;Unless you really need to do this entirely with %let statements, I would just do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;

data _null_;
call symputx("calculatedDate", compress("'" || put(intnx("month", mdy(&amp;amp;mm,1,&amp;amp;yyyy), 1)-1, date9.) || "'"));
run;
%put &amp;amp;=calculatedDate;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Nov 2025 23:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979074#M46271</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-11-18T23:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979076#M46272</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-find-the-last-day-of-the-month/td-p/733782" target="_blank"&gt;Solved: How to find the last day of the month - SAS Support Communities&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/10/30/first-last-day-of-month-year.html" target="_blank"&gt;Compute the first or last day of a month or year - The DO Loop&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ciao,&lt;BR /&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 00:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979076#M46272</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2025-11-19T00:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979079#M46273</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let calculatedDate = %sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.);
%put &amp;amp;=calculatedDate;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;159  %let mm=09;
160  %let yyyy=2025;
161  %let calculatedDate = %sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.);
162  %put &amp;amp;=calculatedDate;
CALCULATEDDATE=2025-09-30
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Nov 2025 07:30:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979079#M46273</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-19T07:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979124#M46275</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let EOM = %sysfunc(quote(%sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.),%str(%'))); /* EOM = End Of the Month */
%put &amp;amp;=EOM;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Nov 2025 14:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979124#M46275</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-11-19T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979125#M46276</link>
      <description>&lt;P&gt;I'm curious why you marked a solution correct when that solution didn't meet the requirements of having the date within single quotes. Is that no longer a requirement?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979125#M46276</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-11-19T15:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979126#M46277</link>
      <description>&lt;P&gt;pertinent remark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I enriched the solution of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;with an extra line to have the single quotes around the formatted date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let calculatedDate = %sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.);
%put &amp;amp;=calculatedDate;

%let calculatedDateWithSingleQuotes = %str(%')&amp;amp;calculatedDate%str(%');
%put &amp;amp;=calculatedDateWithSingleQuotes;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ciao,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979126#M46277</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2025-11-19T15:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979128#M46279</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would like to get this macro variable calculatedDate equal to : '2025-09-30' and between single quote&lt;/P&gt;
&lt;P&gt;Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let calculatedDate = %sysfunc(INTNX("MONTH", MDY(&amp;amp;mm., 1, &amp;amp;yyyy.), 1)-1);
%put &amp;amp;=calculatedDate;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First thing is the the INTNX() function is not going to understand an interval name that includes quote characters in it.&amp;nbsp; &amp;nbsp;It is also not going to like receiving a string for an argument that requires a DATE value. Try it in normal SAS code and see what it does.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  date = intnx('"MONTH"','MDY(09, 1, 2025)',1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want the macro processor to run the MDY() function you need to also wrap it inside the %SYSFUNC() macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also if you want INTNX() to return the end of the interval instead of the beginning of the interval then just tell it so instead of accepting the default of the beginning of the value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you want the date formatted as a string in YYYY-MM-DD style then tell %SYSFUNC() to use the YYMMDD10. format when returning its result, instead of just converting the date into a digit string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let calculatedDate = %sysfunc(MDY(&amp;amp;mm,1,&amp;amp;yyyy));
%let calculatedDate = %sysfunc(INTNX(MONTH,&amp;amp;calculatedDate,0,end),yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use %BQUOTE() to add single quotes and still resolve macro variable references.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let calculatedDate = %bquote('&amp;amp;calculatedDate');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the macro quoting that %BQUOTE() adds causes trouble then remove it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let calculatedDate = %unquote(&amp;amp;calculatedDate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could nest the function calls, but why make the code harder to understand?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979128#M46279</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-11-19T15:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979129#M46280</link>
      <description>No it seems that I need the single quote with a snowflake sql query.  But it is a way to thanks that person for giving me the major part of the solution.</description>
      <pubDate>Wed, 19 Nov 2025 15:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979129#M46280</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-11-19T15:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979134#M46282</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No it seems that I need the single quote with a snowflake sql query. But it is a way to thanks that person for giving me the major part of the solution.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Okay that's a good thing to do, but it would be even better if you explained to us why it was marked correct, without us having to ask.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 15:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979134#M46282</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-11-19T15:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979168#M46288</link>
      <description>&lt;P&gt;As Tom showed you ,if you need add single quote ,you need use macro masked function %bquote() or %superq() or %str().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mm=09;
%let yyyy=2025;
%let calculatedDate ='%sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.)';
%put %bquote(&amp;amp;calculatedDate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;5    %let mm=09;
6    %let yyyy=2025;
7    %let calculatedDate ='%sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.)';
8    %put %bquote(&amp;amp;calculatedDate);
'2025-09-30'

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you are running into some problem, you also need help of&amp;nbsp; %unquote() as Tom showed you .&lt;/P&gt;
&lt;PRE&gt;%unquote(  %bquote(&amp;amp;calculatedDate)  );&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Nov 2025 07:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979168#M46288</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-20T07:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979199#M46289</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I didn't think your code would work because calculatedDate stores a single quoted string with calls to %sysfunc:&lt;/P&gt;
&lt;PRE&gt;1    %let mm=09;
2    %let yyyy=2025;
3    %let calculatedDate ='%sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.)';
4    %put &amp;amp;=calculatedDate;
CALCULATEDDATE='%sysfunc(INTNX(MONTH, %sysfunc(MDY(&amp;amp;mm., 1, &amp;amp;yyyy.)),0,e),yymmdd10.)'
&lt;/PRE&gt;
&lt;P&gt;I guess I forgot (or never knew?) that %bquote will resolve macro triggers inside a single quoted string.&lt;/P&gt;
&lt;PRE&gt;5    %put %bquote(&amp;amp;calculatedDate);
'2025-09-30'
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Nov 2025 13:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979199#M46289</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2025-11-20T13:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to get the last day of the month using %sysfunc and intnx function</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979273#M46290</link>
      <description>Quentin,&lt;BR /&gt;Yes.  %bquote will  mask single quote inside a macro variable. As Tom already said and showed .</description>
      <pubDate>Fri, 21 Nov 2025 06:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-get-the-last-day-of-the-month-using-sysfunc-and-intnx/m-p/979273#M46290</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-21T06:32:11Z</dc:date>
    </item>
  </channel>
</rss>

