<?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 form a loop of 12 month date values with change in every quarterly Date values in SAS DI in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563615#M158031</link>
    <description>&lt;P&gt;The first obvious problem is that date literals have to be in a form that the DATE informat can read.&lt;/P&gt;
&lt;P&gt;Is there a pattern to those dates?&amp;nbsp; Some appear the be the last day of a quarter, like June 30th.&amp;nbsp; But other, like March 30th, are the next to last day of the quarter.&lt;/P&gt;
&lt;P&gt;Why are you using INTNX() to move by 12 months instead of 1 year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this sentence mean?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need a table wherein for every quarter date values, I get last 12 month values iteratively.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What&amp;nbsp; is the over all goal of this exercise?&amp;nbsp; Are you trying to replicate your data?&amp;nbsp; Collapse it into intervals? (isn't that what the DATE_QUARTER variable already does?)&amp;nbsp; Summarize it some how?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jun 2019 22:27:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-04T22:27:41Z</dc:date>
    <item>
      <title>How to form a loop of 12 month date values with change in every quarterly Date values in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563610#M158026</link>
      <description>&lt;P&gt;&amp;nbsp;I am new to SAS DI. I have one column with monthly date values (DATE) and one column with corresponding quarter values (Date_quarter).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a table wherein for every quarter date values, I get last 12 month values iteratively. Now I am not sure, how to do it SAS DI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I have done is in SAS Enterprise Guide, created a macro variable, vdatum, which takes every quarter end values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vdatum1 = '30.03.2016'd;&lt;/P&gt;&lt;P&gt;%let vdatum2 = '30.06.2016'd;&lt;/P&gt;&lt;P&gt;%let vdatum3 = '29.09.2016'd;&lt;/P&gt;&lt;P&gt;%let vdatum4 = '30.12.2016'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let vdatum5 = '30.03.2017'd;&lt;/P&gt;&lt;P&gt;%letvdatum6 = '30.06.2017'd;&lt;/P&gt;&lt;P&gt;%let vdatum7 = '29.09.2017'd;&lt;/P&gt;&lt;P&gt;%let vdatum8 = '30.12.2017'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro loop(iteration_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;%do i= 1 %to &amp;amp;iteration_number;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; data loop_trial;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set trial.data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; where date &amp;gt; intnx('month',&amp;amp;&amp;amp;vdatum&amp;amp;i.,-12,'sameday') and date &amp;lt;= &amp;amp;&amp;amp;vdatum&amp;amp;i.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Date_quarter = intnx('qtr',&amp;amp;&amp;amp;vdatum&amp;amp;i.,0,'beginning');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%loop(8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 21:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563610#M158026</guid>
      <dc:creator>Neha8</dc:creator>
      <dc:date>2019-06-04T21:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a loop of 12 month date values with change in every quarterly Date values in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563615#M158031</link>
      <description>&lt;P&gt;The first obvious problem is that date literals have to be in a form that the DATE informat can read.&lt;/P&gt;
&lt;P&gt;Is there a pattern to those dates?&amp;nbsp; Some appear the be the last day of a quarter, like June 30th.&amp;nbsp; But other, like March 30th, are the next to last day of the quarter.&lt;/P&gt;
&lt;P&gt;Why are you using INTNX() to move by 12 months instead of 1 year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this sentence mean?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need a table wherein for every quarter date values, I get last 12 month values iteratively.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What&amp;nbsp; is the over all goal of this exercise?&amp;nbsp; Are you trying to replicate your data?&amp;nbsp; Collapse it into intervals? (isn't that what the DATE_QUARTER variable already does?)&amp;nbsp; Summarize it some how?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 22:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563615#M158031</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-04T22:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a loop of 12 month date values with change in every quarterly Date values in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563617#M158033</link>
      <description>&lt;P&gt;are you looking for engagement into an event during the last 12 months?&amp;nbsp; basically creating a window period of time?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 22:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563617#M158033</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-04T22:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a loop of 12 month date values with change in every quarterly Date values in SAS DI</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563618#M158034</link>
      <description>&lt;P&gt;I started this, but realized I was on the wrong track:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start = 30MAR2016;
%let num   = 8;

* dummy format for debugging ;
proc format;
   value dates2qtrnum
      1 -&amp;lt; 2 = 3
   ;
run;

* view the structure of the cntlout table ;
proc format cntlout=cntlout;
run;

* create desired cntlin table ;
data cntlin;
   length fmtname $32 start end label 8 type eexcl $1;
   fmtname="DATES2QTRGRP";
   type="N";
   eexcl="Y";
   start="&amp;amp;start"d;
   do label=1 to &amp;amp;num;
      end=intnx('qtr',"&amp;amp;start"d,label,'B');
      output;
      start=end;
   end;
   format start end date9.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the concept is to:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create a range format to group your data into the correct buckets.&lt;/LI&gt;
&lt;LI&gt;Apply the format to your dates to derive the correct bucket.&lt;/LI&gt;
&lt;LI&gt;Use BY processing to split your data&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;As far as how to do this in DI, once you get the correct code running in EG, just use a user-written transformation and post your working code into DI.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 22:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-form-a-loop-of-12-month-date-values-with-change-in-every/m-p/563618#M158034</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2019-06-04T22:40:50Z</dc:date>
    </item>
  </channel>
</rss>

