<?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 Choose specific date in a week based on a date variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591631#M169525</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;Is there a way to pick a specific date of the given week depending on the date.&lt;BR /&gt;&lt;BR /&gt;If I have records as:&lt;BR /&gt;&lt;BR /&gt;Name Date&lt;BR /&gt;AD Sept 11&lt;BR /&gt;DF Sept 16&lt;BR /&gt;&lt;BR /&gt;I want to pick be able to pick the Wednesday of the week and report it. Output would look like:&lt;BR /&gt;&lt;BR /&gt;Name &amp;nbsp; Date &amp;nbsp; &amp;nbsp; &amp;nbsp; Week_date&lt;BR /&gt;AD &amp;nbsp; &amp;nbsp; &amp;nbsp; Sept 12 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sep 11&lt;BR /&gt;DF &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sept 16 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sep 18&lt;BR /&gt;&lt;BR /&gt;I know i can just define the ranges in a data step but I wanted to know if there way a different way to do this... The week would be Sun - Sat&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2019 17:49:52 GMT</pubDate>
    <dc:creator>TheNovice</dc:creator>
    <dc:date>2019-09-25T17:49:52Z</dc:date>
    <item>
      <title>Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591631#M169525</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Is there a way to pick a specific date of the given week depending on the date.&lt;BR /&gt;&lt;BR /&gt;If I have records as:&lt;BR /&gt;&lt;BR /&gt;Name Date&lt;BR /&gt;AD Sept 11&lt;BR /&gt;DF Sept 16&lt;BR /&gt;&lt;BR /&gt;I want to pick be able to pick the Wednesday of the week and report it. Output would look like:&lt;BR /&gt;&lt;BR /&gt;Name &amp;nbsp; Date &amp;nbsp; &amp;nbsp; &amp;nbsp; Week_date&lt;BR /&gt;AD &amp;nbsp; &amp;nbsp; &amp;nbsp; Sept 12 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sep 11&lt;BR /&gt;DF &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sept 16 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Sep 18&lt;BR /&gt;&lt;BR /&gt;I know i can just define the ranges in a data step but I wanted to know if there way a different way to do this... The week would be Sun - Sat&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 17:49:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591631#M169525</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-09-25T17:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591634#M169528</link>
      <description>&lt;P&gt;Without complete dates (years!), you can't do that.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 17:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591634#M169528</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-25T17:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591636#M169530</link>
      <description>&lt;P&gt;Sorry for the shoddy post Kurt...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I will have the full date with year in there.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 17:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591636#M169530</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-09-25T17:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591647#M169536</link>
      <description>&lt;P&gt;The weekday() function yields a number between 1 and 7 that specifies the day in the week (1 = Sunday, 7 = Saturday).&lt;/P&gt;
&lt;P&gt;This can be used in a rather simple formula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
format date wednesday weekdatx.;
do date = today() - 7 to today() + 7;
  wednesday = date + 4 - weekday(date);
  output;
end;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;date	                        wednesday
Wednesday, 18 September 2019	Wednesday, 18 September 2019
Thursday, 19 September 2019	Wednesday, 18 September 2019
Friday, 20 September 2019	Wednesday, 18 September 2019
Saturday, 21 September 2019	Wednesday, 18 September 2019
Sunday, 22 September 2019	Wednesday, 25 September 2019
Monday, 23 September 2019	Wednesday, 25 September 2019
Tuesday, 24 September 2019	Wednesday, 25 September 2019
Wednesday, 25 September 2019	Wednesday, 25 September 2019
Thursday, 26 September 2019	Wednesday, 25 September 2019
Friday, 27 September 2019	Wednesday, 25 September 2019
Saturday, 28 September 2019	Wednesday, 25 September 2019
Sunday, 29 September 2019	Wednesday, 2 October 2019
Monday, 30 September 2019	Wednesday, 2 October 2019
Tuesday, 1 October 2019	        Wednesday, 2 October 2019
Wednesday, 2 October 2019	Wednesday, 2 October 2019
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591647#M169536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-25T18:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591662#M169541</link>
      <description>&lt;P&gt;I'd recommend INTNX() instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;wednesday = intnx('week', date, 0, 'b') + 3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The third parameter, the interval, is set to 0 to stay on the same week.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'b' aligns it to the beginning of the week, Sunday.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;+3 adds 3 days to get it to Wednesday.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will give the Wednesday of the week, regardless if it's before or after the date.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/591662#M169541</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-25T18:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/599044#M172842</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 14:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/599044#M172842</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-10-24T14:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Choose specific date in a week based on a date variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/599045#M172843</link>
      <description>&lt;P&gt;Thanks Reeza, I will try this today. Apologies for the delay. Got pulled onto another task.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 14:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choose-specific-date-in-a-week-based-on-a-date-variable/m-p/599045#M172843</guid>
      <dc:creator>TheNovice</dc:creator>
      <dc:date>2019-10-24T14:18:33Z</dc:date>
    </item>
  </channel>
</rss>

