<?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: Extracting rows based on different weekdays in DI Studio in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125923#M1616</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you already figured a valid where expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background-color: #ffffff;"&gt;where:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;(weekday("&amp;amp;sysdate"d) = 2 and &lt;SPAN style="font-family: 'Courier New'; background-color: #ffffff;"&gt;("&amp;amp;sysdate"d-1)&lt;/SPAN&gt; &amp;lt;= LAST_CHANGED between &amp;lt;= ("&amp;amp;sysdate"d-3)) or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt; (weekday("&amp;amp;sysdate"d) in (3,4,5,6) and LAST_CHANGED = "&amp;amp;sysdate"d-1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This should extract everything you need.&lt;/P&gt;&lt;P&gt;If LAST_CHANGED is in a date/time form, just apply the DATEPART function to extract the Date portion of it, as the "&amp;amp;SYSDATE" var is represented with a Date only format (DATE9.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More on DATEPART function here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2012 07:25:45 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2012-09-20T07:25:45Z</dc:date>
    <item>
      <title>Extracting rows based on different weekdays in DI Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125922#M1615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd appreciate good advice on a problem I'm faced with in DI Studio.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My job includes a source table and an extract transformation. The source table has a datetime variable called "Last_Changed". If today is Monday, the Extract must get all rows where the Last_Changed weekday is between Fri-Sun the previous week. If today to Tue-Fri, the Extract must get all rows from yesterday. I've figured out some of the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If weekday(&amp;amp;sysdate"d) = 2 (Monday), extract all rows where "Last_Changed" between "&amp;amp;sysdate"d-3 and "&amp;amp;sysdate"d-1 (previous Friday-Sunday). Else, if weekday(&amp;amp;sysdate"d) in (3,4,5,6) (Tuesday-Friday), extract all rows where "&amp;amp;sysdate"d = today()-1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that I can't quite figure out how to set this up in the Extract precode and where-statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 06:55:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125922#M1615</guid>
      <dc:creator>TurnTheBacon</dc:creator>
      <dc:date>2012-09-20T06:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting rows based on different weekdays in DI Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125923#M1616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you already figured a valid where expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background-color: #ffffff;"&gt;where:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;(weekday("&amp;amp;sysdate"d) = 2 and &lt;SPAN style="font-family: 'Courier New'; background-color: #ffffff;"&gt;("&amp;amp;sysdate"d-1)&lt;/SPAN&gt; &amp;lt;= LAST_CHANGED between &amp;lt;= ("&amp;amp;sysdate"d-3)) or&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt; (weekday("&amp;amp;sysdate"d) in (3,4,5,6) and LAST_CHANGED = "&amp;amp;sysdate"d-1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; background-color: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This should extract everything you need.&lt;/P&gt;&lt;P&gt;If LAST_CHANGED is in a date/time form, just apply the DATEPART function to extract the Date portion of it, as the "&amp;amp;SYSDATE" var is represented with a Date only format (DATE9.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More on DATEPART function here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245883.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers from Portugal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 07:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125923#M1616</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2012-09-20T07:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting rows based on different weekdays in DI Studio</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125924#M1617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can try this code...not tested in DI...&lt;/P&gt;&lt;P&gt;%let dd=%sysfunc(weekday(%sysfunc(today(),DDMMYY10)));&lt;/P&gt;&lt;P&gt;%put &amp;amp;dd;&lt;/P&gt;&lt;P&gt;options minoperator;&lt;/P&gt;&lt;P&gt;%macro test/mindelimiter=',';&lt;/P&gt;&lt;P&gt;%if &amp;amp;dd in 3,4,5,6 %then %do;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set &amp;amp;syslast;&lt;/P&gt;&lt;P&gt;where date between "&amp;amp;sysdate"d-3 and "&amp;amp;sysdate"d-1 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%else %if &amp;amp;dd =2 %then %do;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set &amp;amp;Syslast;&lt;/P&gt;&lt;P&gt;where date between "&amp;amp;sysdate"d and "&amp;amp;sysdate"d-1 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 09:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Extracting-rows-based-on-different-weekdays-in-DI-Studio/m-p/125924#M1617</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-09-20T09:42:03Z</dc:date>
    </item>
  </channel>
</rss>

