<?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: Group data into specific days of the week in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/805255#M317193</link>
    <description>&lt;P&gt;Although I haven't worked through all the details, I believe you can create a custom format using PROC FCMP to accomplish this. Here's a similar example:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1gg77jyhc9s42n1f1vjyx2hsg8b.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1gg77jyhc9s42n1f1vjyx2hsg8b.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 13:08:57 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-03-31T13:08:57Z</dc:date>
    <item>
      <title>Group data into specific days of the week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804360#M316746</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; I have data with a date (closing_date) spanning out to 120 days.. I'm trying to group them by different Thursday to Wednesday groupings and name them like "March-10-22 - March-16-22'... and show about 17 groupings each one with a Thr-Wed title..&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 12:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804360#M316746</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2022-03-27T12:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Group data into specific days of the week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804371#M316749</link>
      <description>&lt;P&gt;I would try something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  do closing_dat = today() - 60 to today() + 60;
    output;
  end;
  format closing_dat yymmdd10.;
run;

%let last_day=4; /* 4 = Thursday */
%let format = worddate12.;

data want;
  do _N_ = 1 by 1 until(weekday(closing_dat) = &amp;amp;last_day. or EOF);
    set have end=EOF;

    if _N_=1 then dt = closing_dat;

    if weekday(closing_dat) = &amp;amp;last_day. or EOF then
      label = catx(" - ",put(dt,&amp;amp;format.),put(closing_dat,&amp;amp;format.));
  end;

  do _N_ = 1 to _N_;
    set have;
    output;
  end;
  drop dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 13:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804371#M316749</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-03-27T13:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Group data into specific days of the week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804536#M316840</link>
      <description>&lt;P&gt;My take:&lt;/P&gt;
&lt;PRE&gt;data example;
   somedate = '15Feb2022'd;
   do closing_date= somedate to (somedate+120);
      weekstart = intnx('week.5',closing_date,0,'B');
      weekend  = intnx('week.5',closing_date,0,'E');
      text = catx('-',put(weekstart,worddate12.),put(weekend,worddate12.));
      output;
   end;

   format closing_date date9. weekstart weekend date9.;
run; &lt;/PRE&gt;
&lt;P&gt;The INTNX function can use offsets to define the boundary of the interval.&lt;/P&gt;
&lt;P&gt;I show creating some text as requested but I would, if this were my project stick with the WEEKSTART variable and not bother showing the end unless I went to considerable work to use a function to create a possibly obnoxious format. Why would I do that? Because none of the text formats for dates except YYYYMMDD types sort at all correctly and as soon as you go to make a table with that text your going to have something like&lt;/P&gt;
&lt;P&gt;Apr 14&amp;nbsp; 2022&lt;/P&gt;
&lt;P&gt;Apr 21 2022&lt;/P&gt;
&lt;P&gt;Apr 28 2022&lt;/P&gt;
&lt;P&gt;Then Feb&lt;/P&gt;
&lt;P&gt;Then Jun&lt;/P&gt;
&lt;P&gt;Then Mar&lt;/P&gt;
&lt;P&gt;Then May&lt;/P&gt;
&lt;P&gt;(for example with 120 days starting in Feb)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 15:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/804536#M316840</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-28T15:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Group data into specific days of the week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/805254#M317192</link>
      <description>Thank you , this is great</description>
      <pubDate>Thu, 31 Mar 2022 12:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/805254#M317192</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2022-03-31T12:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Group data into specific days of the week</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/805255#M317193</link>
      <description>&lt;P&gt;Although I haven't worked through all the details, I believe you can create a custom format using PROC FCMP to accomplish this. Here's a similar example:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1gg77jyhc9s42n1f1vjyx2hsg8b.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/p1gg77jyhc9s42n1f1vjyx2hsg8b.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 13:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-data-into-specific-days-of-the-week/m-p/805255#M317193</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-31T13:08:57Z</dc:date>
    </item>
  </channel>
</rss>

