<?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: Grouping Results by custom data intervals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579564#M164515</link>
    <description>&lt;P&gt;Look at proc freq.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2019 05:58:31 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-08-07T05:58:31Z</dc:date>
    <item>
      <title>Grouping Results by custom data intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579555#M164511</link>
      <description>&lt;P&gt;I am trying to group my data into the following data ranges, it's not working and I am still learning my way around SAS. Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data=contact_date_interval;&lt;BR /&gt;set work.contact_ind;&lt;BR /&gt;format EFFECTIVE_FROM date9.;&lt;BR /&gt;date=datepart(EFFECTIVE_FROM);&lt;BR /&gt;if date &amp;gt;= '01NOV2018'd and date &amp;lt;= '28Feb2019'D then&lt;BR /&gt;Group ="1Nov2018 - 28Feb2019";&lt;BR /&gt;else if date &amp;gt;='01MAR2019'D and date &amp;lt;='06MAY2019'D then&lt;BR /&gt;Group = "1March - 6May2019";&lt;BR /&gt;else if date &amp;gt;='07MAY2019'D and date &amp;lt;='31MAY2019'D then&lt;BR /&gt;Group = "7May - 31May2019";&lt;BR /&gt;else if date &amp;gt;='01JUN2019'D and date &amp;lt;='31JUL2019'D then&lt;BR /&gt;Group = "1Jun - 31Jul2019";&lt;BR /&gt;else Group ='Other';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also like to view the results as a count.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 04:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579555#M164511</guid>
      <dc:creator>RALL</dc:creator>
      <dc:date>2019-08-07T04:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Results by custom data intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579556#M164512</link>
      <description>&lt;P&gt;1. Remove the = sign on the first line&lt;/P&gt;
&lt;P&gt;2. The code seems fine. What error do you get?&lt;/P&gt;
&lt;P&gt;3. This is easier to read:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CONTACT_DATE_INTERVAL;
  set WORK.CONTACT_IND;
  format EFFECTIVE_FROM date9.;
  DATE=datepart(EFFECTIVE_FROM);
  if      '01NOV2018'd &amp;lt;= DATE &amp;lt;= '28FEB2019'd then GROUP = "1Nov2018 - 28Feb2019";
  else if '01MAR2019'd &amp;lt;= DATE &amp;lt;= '06MAY2019'd then GROUP = "1March - 6May2019";
  else if '07MAY2019'd &amp;lt;= DATE &amp;lt;= '31MAY2019'd then GROUP = "7May - 31May2019";
  else if '01JUN2019'd &amp;lt;= DATE &amp;lt;= '31JUL2019'd then GROUP = "1Jun - 31Jul2019";
  else                                              GROUP = 'Other';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 04:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579556#M164512</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-08-07T04:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Results by custom data intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579557#M164513</link>
      <description>&lt;P&gt;It ran when I used yours, I am assuming it was the = in the beginning or the order. If I wanted to have a table of the counts in those date ranges what would the code for that look like?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 05:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579557#M164513</guid>
      <dc:creator>RALL</dc:creator>
      <dc:date>2019-08-07T05:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Results by custom data intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579564#M164515</link>
      <description>&lt;P&gt;Look at proc freq.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 05:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579564#M164515</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-08-07T05:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping Results by custom data intervals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579674#M164568</link>
      <description>&lt;P&gt;You may want to consider a custom format such as:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value dategroup
'01NOV2018'd - '28FEB2019'd = "1Nov2018 - 28Feb2019"
'01MAR2019'd - '06MAY2019'd = "1March - 6May2019"
'07MAY2019'd - '31MAY2019'd = "7May - 31May2019"
'01JUN2019'd - '31JUL2019'd = "1Jun - 31Jul2019"
other= 'Other';
run;

proc freq data=work.contact_date_interval;
   tables date;
   format date dategroup.;
run;&lt;/PRE&gt;
&lt;P&gt;Without explicitly creating a group variable and using the format associated with the date if you have to add another interval late such as 1Aug2019- 4Sep2019. Then by changing the format the group will change with the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Categories created with formats will be used by most analysis, reporting and graphing procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And actually a format could be made using your raw datetime values as well..&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 15:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-Results-by-custom-data-intervals/m-p/579674#M164568</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-07T15:31:02Z</dc:date>
    </item>
  </channel>
</rss>

