<?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: Getinng the first day of quarter with intnx function giving odd results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672076#M201911</link>
    <description>&lt;P&gt;I cannot see how the code you show produces anything that looks like a date or datetime value. You need a %sysfunc or two. Are you sure that is the exact code you are using?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code works for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=%sysfunc(intnx(qtr,%sysfunc(today()),0,b));
%put &amp;amp;=q1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 24 Jul 2020 12:27:53 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-07-24T12:27:53Z</dc:date>
    <item>
      <title>Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672069#M201908</link>
      <description>&lt;P&gt;I tried to get the first day of current quarter with this code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=intnx('qtr', today(),0,'b');

%put &amp;amp;q1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This gives me the result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;01JAN1960:06:08:17.000&lt;/FONT&gt; instead of&amp;nbsp;&lt;FONT color="#339966"&gt;01JUN2020:00:00:00&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 12:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672069#M201908</guid>
      <dc:creator>sasuser381</dc:creator>
      <dc:date>2020-07-24T12:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672072#M201909</link>
      <description>Edit:&lt;BR /&gt;&lt;BR /&gt;It gives me the result 01JAN1960:06:08:17</description>
      <pubDate>Fri, 24 Jul 2020 12:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672072#M201909</guid>
      <dc:creator>sasuser381</dc:creator>
      <dc:date>2020-07-24T12:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672076#M201911</link>
      <description>&lt;P&gt;I cannot see how the code you show produces anything that looks like a date or datetime value. You need a %sysfunc or two. Are you sure that is the exact code you are using?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code works for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=%sysfunc(intnx(qtr,%sysfunc(today()),0,b));
%put &amp;amp;=q1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 12:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672076#M201911</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-24T12:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672079#M201913</link>
      <description>This is the whole code:&lt;BR /&gt;&lt;BR /&gt;%let q1=intnx('qtr', today(),0,'b');&lt;BR /&gt;%put &amp;amp;q1;&lt;BR /&gt;&lt;BR /&gt;DATA Q1CHECK;&lt;BR /&gt;Q1=&amp;amp;Q1; FORMAT Q1 DATETIME16.;&lt;BR /&gt;RUN;&lt;BR /&gt;</description>
      <pubDate>Fri, 24 Jul 2020 12:39:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672079#M201913</guid>
      <dc:creator>sasuser381</dc:creator>
      <dc:date>2020-07-24T12:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672082#M201915</link>
      <description>&lt;P&gt;You want to use a date format, not a datetime format.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 12:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672082#M201915</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-24T12:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672084#M201917</link>
      <description>Well i need datetime format actualy as an output. How could i do that? Obviously not this way i did.</description>
      <pubDate>Fri, 24 Jul 2020 12:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672084#M201917</guid>
      <dc:creator>sasuser381</dc:creator>
      <dc:date>2020-07-24T12:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672093#M201925</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217737"&gt;@sasuser381&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well i need datetime format actualy as an output. How could i do that? Obviously not this way i did.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to use datetime values (number of seconds) not date values (number of days) with the DATETIME format. Use the DTQTR interval instead of the QTR interval when working with seconds instead of days.&lt;/P&gt;
&lt;PRE&gt;340   data _null_;
341     now=datetime();
342     qtr=intnx('dtqtr',now,0,'b');
343     put (now qtr) (datetime19.);
344   run;

 24JUL2020:09:49:55 01JUL2020:00:00:00
&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 13:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672093#M201925</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-24T13:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672108#M201936</link>
      <description>&lt;P&gt;In SAS macro code you need to wrap datastep function in %sysfunc unless you have macro equivalent such as %scan. In your case it will be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=intnx('qtr', %sysfunc(today()) ,0,'b');

%put &amp;amp;q1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 15:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672108#M201936</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-24T15:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672114#M201941</link>
      <description>&lt;P&gt;1. Functions need to be wrapped in %SYSFUNC()&lt;/P&gt;
&lt;P&gt;2. For datetime variables the increment needs to start with DT&lt;/P&gt;
&lt;P&gt;3. When using functions within macro code, you do not need quotes.&lt;/P&gt;
&lt;P&gt;4. TODAY() returns a DATE variable, if you want DATETIME use DATETIME() function instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=%sysfunc(intnx(dtqtr, %sysfunc(datetime()), 0, b), datetime.);

%put &amp;amp;q1.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let q1=%sysfunc(intnx(dtqtr, %sysfunc(datetime()), 0, b), datetime.);
 70         
 71         %put &amp;amp;q1.;
 01JUL20:00:00:00
 72         
 73         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 83         &lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/217737"&gt;@sasuser381&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried to get the first day of current quarter with this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let q1=intnx('qtr', today(),0,'b');

%put &amp;amp;q1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This gives me the result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;01JAN1960:06:08:17.000&lt;/FONT&gt; instead of&amp;nbsp;&lt;FONT color="#339966"&gt;01JUN2020:00:00:00&lt;/FONT&gt;&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;</description>
      <pubDate>Fri, 24 Jul 2020 15:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672114#M201941</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-24T15:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Getinng the first day of quarter with intnx function giving odd results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672142#M201956</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let q1=%sysfunc(intnx(qtr,%sysfunc(today()),0,b),datetime20.);

/* %let q1=intnx('qtr', today(),0,'b'); */

%put &amp;amp;q1;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jul 2020 18:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getinng-the-first-day-of-quarter-with-intnx-function-giving-odd/m-p/672142#M201956</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2020-07-24T18:06:11Z</dc:date>
    </item>
  </channel>
</rss>

