<?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 Create time interval automatically in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339068#M22515</link>
    <description>&lt;P&gt;So we have one dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Start_date   End_date      Month_Interval
01JAN2001    31DEC2002        6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with 'Start_date',&amp;nbsp;&lt;SPAN&gt;'End&lt;/SPAN&gt;&lt;SPAN&gt;_date' having&amp;nbsp;date values, and 'Month_Interval' having numeric values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want to create a new dataset based on the data above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Time_Period
1/2001 - 6/2001
7/2001 - 12/2001
1/2002 - 6/2002
7/2002 - 12/2002&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with 'Time_Period' having character values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the interval starts on '01JAN2001', there are&amp;nbsp;6 months in each interval, and the period ends on '31DEC2002'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should we achieve this?&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2017 01:15:01 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-03-08T01:15:01Z</dc:date>
    <item>
      <title>Create time interval automatically</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339068#M22515</link>
      <description>&lt;P&gt;So we have one dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Start_date   End_date      Month_Interval
01JAN2001    31DEC2002        6&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with 'Start_date',&amp;nbsp;&lt;SPAN&gt;'End&lt;/SPAN&gt;&lt;SPAN&gt;_date' having&amp;nbsp;date values, and 'Month_Interval' having numeric values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want to create a new dataset based on the data above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Time_Period
1/2001 - 6/2001
7/2001 - 12/2001
1/2002 - 6/2002
7/2002 - 12/2002&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with 'Time_Period' having character values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the interval starts on '01JAN2001', there are&amp;nbsp;6 months in each interval, and the period ends on '31DEC2002'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should we achieve this?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 01:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339068#M22515</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-08T01:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create time interval automatically</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339073#M22517</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dsd dlm=',';
attrib start_date end_date length=4 informat=date9. format=monyy7.;
attrib interval length=3;
input start_date
      end_date
      interval;
cards;
01JAN2001,31DEC2002,6
;
run;&lt;BR /&gt;

data want;
set have;
length time_period $ 17;
do i = start_date to end_date by interval * 31;
   i = intnx('month', i, 0, 'b');
   j = intnx('month', i, interval - 1, 'b');
   time_period = translate(catx(' - ', putn(i, 'mmyy7.'), putn(j, 'mmyy7.')), '/', 'M');
   output;
   end;
keep time_period;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The format&amp;nbsp;&lt;EM&gt;mmyy&lt;/EM&gt; returns mmMyyyy, so the&amp;nbsp;&lt;EM&gt;translate&amp;nbsp;&lt;/EM&gt;function swaps that out for a slash. I could have used something cleverer than&amp;nbsp;&lt;EM&gt;interval&lt;/EM&gt;&lt;EM&gt;&amp;nbsp;* 31&lt;/EM&gt;, but since I reset&amp;nbsp;&lt;EM&gt;i&lt;/EM&gt; to the beginning of the incremented month on the very next line, this will always work; sometimes (often) it's best to keep it simple, and it's easily clear enough what's going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 01:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339073#M22517</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-03-08T01:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create time interval automatically</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339084#M22519</link>
      <description>&lt;PRE&gt;

data have;
infile cards dsd dlm=',';
input start_date : date9.
      end_date : date9.
      interval;
format start_date end_date date9.;
cards;
01JAN2001,31DEC2002,6
;
run;
data want;
 set have;
 do while(end lt end_date);
  end=intnx('month',start_date,interval-1,'e');output;
  start_date=intnx('month',end,1);
 end;
 format start_date end mmyys7.;
 drop end_date;
run;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2017 02:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339084#M22519</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-08T02:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create time interval automatically</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339096#M22520</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   length start_date end_date month_interval 8;
   input start_date end_date month_interval;
   informat start_date end_date date9.;
   format start_date end_date date9.;
   datalines;
01JAN2001   31DEC2002   6
;
run;

data want;
   length time_period $20;
   set have;
   start=start_date;
   do until (end ge end_date);
      end=intnx("month",start,month_interval-1,"E");
      time_period=catx(" - ",put(start,mmyys7.),put(end,mmyys7.));
      output;
      start=intnx("month",end,1,"B");
   end;
   format start end date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2017 04:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-time-interval-automatically/m-p/339096#M22520</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2017-03-08T04:48:34Z</dc:date>
    </item>
  </channel>
</rss>

