<?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 How to group week wise with date range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339110#M77351</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have task date range please help me for the below scenorios.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to group with Sunday to Saturday &amp;nbsp;as Week1 in perticular month for example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;March 5th to March 11th it would be "Week1 March" &amp;nbsp;and March 12th To March 18th it would be "Week2 March"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 06:52:22 GMT</pubDate>
    <dc:creator>srinivaschary</dc:creator>
    <dc:date>2017-03-08T06:52:22Z</dc:date>
    <item>
      <title>How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339110#M77351</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have task date range please help me for the below scenorios.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to group with Sunday to Saturday &amp;nbsp;as Week1 in perticular month for example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;March 5th to March 11th it would be "Week1 March" &amp;nbsp;and March 12th To March 18th it would be "Week2 March"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Srinivas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 06:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339110#M77351</guid>
      <dc:creator>srinivaschary</dc:creator>
      <dc:date>2017-03-08T06:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339134#M77355</link>
      <description>&lt;P&gt;Please post an example data-set and the requested result dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 08:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339134#M77355</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-03-08T08:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339135#M77356</link>
      <description>&lt;P&gt;Use the weekday() function to determine Sundays, and then count the week in a retained variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do day_date = '01mar2017'd to '31mar2017'd;
  output;
end;
format day_date yymmddd10.;
run;

data want;
set have;
retain weekno 0;
length weektext $30;
if weekday(day_date) = 1 then weekno + 1;
if weekno &amp;gt; 0 then weektext = "Week" !! strip(put(weekno,2.)) !! " " !! strip(put(day_date,monname.));
drop weekno;
run;

proc print data=want noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  day_date     weektext

2017-03-01               
2017-03-02               
2017-03-03               
2017-03-04               
2017-03-05    Week1 March
2017-03-06    Week1 March
2017-03-07    Week1 March
2017-03-08    Week1 March
2017-03-09    Week1 March
2017-03-10    Week1 March
2017-03-11    Week1 March
2017-03-12    Week2 March
2017-03-13    Week2 March
2017-03-14    Week2 March
2017-03-15    Week2 March
2017-03-16    Week2 March
2017-03-17    Week2 March
2017-03-18    Week2 March
2017-03-19    Week3 March
2017-03-20    Week3 March
2017-03-21    Week3 March
2017-03-22    Week3 March
2017-03-23    Week3 March
2017-03-24    Week3 March
2017-03-25    Week3 March
2017-03-26    Week4 March
2017-03-27    Week4 March
2017-03-28    Week4 March
2017-03-29    Week4 March
2017-03-30    Week4 March
2017-03-31    Week4 March
&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2017 08:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339135#M77356</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-08T08:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339139#M77357</link>
      <description>&lt;P&gt;You may try using formats as documented in:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604217.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002604217.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2017 08:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/339139#M77357</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-03-08T08:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/912831#M359806</link>
      <description>&lt;P&gt;Hi Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you have given is good for the single ID in the table but we have multiple ids and each ids has a row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data :&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;From date&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;To date&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;03-25-2023&lt;/TD&gt;&lt;TD&gt;09-11-2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;01-07-2022&lt;/TD&gt;&lt;TD&gt;05-10-2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;10-07-2023&lt;/TD&gt;&lt;TD&gt;12-18-2023&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 14:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/912831#M359806</guid>
      <dc:creator>Sastech</dc:creator>
      <dc:date>2024-01-24T14:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to group week wise with date range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/912890#M359825</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/408690"&gt;@Sastech&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your problem/question is about different data then you should start your own thread. Where it is related to another thread you can post a link to it by copying the the URL from your browser and posting into your message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your data is quite different to start with you have to show an example of what you expect for output.&lt;/P&gt;
&lt;P&gt;I have no idea what you expect as you provided no details just that your data is different and multiple ids. Nothing about how the ID would affect the output. Nothing about what the values should be.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 19:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-group-week-wise-with-date-range/m-p/912890#M359825</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-24T19:17:03Z</dc:date>
    </item>
  </channel>
</rss>

