<?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: Data Extraction in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643343#M191992</link>
    <description>&lt;P&gt;Another way to approach this is to maintain a dataset that has a single value...the date it last ran. You then pass that value into a start_date variable that can be used in your program. At the very end, you overwrite the dataset with today's date, that becomes the start date, the next time you run it. This way, if you happen to have a day it can't run during the week, you pick up that data the next day it does run.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mydata "directory_path";
data _null_;
set mydata.last_run_date;
call symputx('start_date',"'"||put(date_last_run,date9.)||"'d");
run;

data want;
set have;
where date_var &amp;gt;= &amp;amp;start_date. and date_var &amp;lt; date();
run;

data mydata.last_run_date;
date_last_run=date();
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 27 Apr 2020 16:36:46 GMT</pubDate>
    <dc:creator>bobpep212</dc:creator>
    <dc:date>2020-04-27T16:36:46Z</dc:date>
    <item>
      <title>Data Extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643332#M191984</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;I am trying to write a code in SAS where from&lt;/P&gt;&lt;P&gt;Tuesday to Friday, it gets data from previous day (Trans_Date is the variable) and on Monday, I want it to get all three days data from the weekend. Appreciate all the help I get.&lt;/P&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Apr 2020 16:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643332#M191984</guid>
      <dc:creator>ARTI1</dc:creator>
      <dc:date>2020-04-27T16:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data Extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643334#M191986</link>
      <description>&lt;P&gt;WEEKDAY() function tells you what day of the week it is.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 16:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643334#M191986</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-27T16:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Data Extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643339#M191990</link>
      <description>&lt;P&gt;First thing is to make sure that you have SAS date valued variables.&lt;/P&gt;
&lt;P&gt;Then there are several date related functions that may help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get specific examples you need to provide data that you have now and what you expect.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 16:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643339#M191990</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-27T16:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data Extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643341#M191991</link>
      <description>This is my SQL code that I need to change it to SAS&lt;BR /&gt;select * into #switch4 from #TransactionsA where trans_date2&amp;gt;= dateadd(dd, case&lt;BR /&gt;substring(datename(dw,getdate()),1,3)&lt;BR /&gt;when 'MON'&lt;BR /&gt;then -3&lt;BR /&gt;else -1 end&lt;BR /&gt;,cast(cast(getdate() as date) as datetime))</description>
      <pubDate>Mon, 27 Apr 2020 16:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643341#M191991</guid>
      <dc:creator>ARTI1</dc:creator>
      <dc:date>2020-04-27T16:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Data Extraction</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643343#M191992</link>
      <description>&lt;P&gt;Another way to approach this is to maintain a dataset that has a single value...the date it last ran. You then pass that value into a start_date variable that can be used in your program. At the very end, you overwrite the dataset with today's date, that becomes the start date, the next time you run it. This way, if you happen to have a day it can't run during the week, you pick up that data the next day it does run.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mydata "directory_path";
data _null_;
set mydata.last_run_date;
call symputx('start_date',"'"||put(date_last_run,date9.)||"'d");
run;

data want;
set have;
where date_var &amp;gt;= &amp;amp;start_date. and date_var &amp;lt; date();
run;

data mydata.last_run_date;
date_last_run=date();
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Apr 2020 16:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Extraction/m-p/643343#M191992</guid>
      <dc:creator>bobpep212</dc:creator>
      <dc:date>2020-04-27T16:36:46Z</dc:date>
    </item>
  </channel>
</rss>

