<?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: Optimizing Code/SAS Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796829#M255727</link>
    <description>&lt;P&gt;Hey &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, where would I be without you? Your solutions works like magic. I really appreciate it, God bless you.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 10:26:26 GMT</pubDate>
    <dc:creator>Solly7</dc:creator>
    <dc:date>2022-02-17T10:26:26Z</dc:date>
    <item>
      <title>Optimizing Code/SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796817#M255719</link>
      <description>&lt;P&gt;Hi, I need help with the below,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my &lt;STRONG&gt;proc sql&lt;/STRONG&gt; code will extract all the data from &lt;STRONG&gt;Transactions&lt;/STRONG&gt; table and then the &lt;STRONG&gt;data step&lt;/STRONG&gt; will filter for data processed only on 15FEB2022 if we run the code Today which is correct. So what I want is to get rid of data step and use only proc sql statement maybe with macro to achieve the results inside the proc sql code only, im not sure how&amp;nbsp; I should do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason is because my source has extremely large data and when i query everything it takes longer to run, the&amp;nbsp;&lt;SPAN&gt;idea is to filter the data from source(Transactions table) so that it extracts only whats required.&amp;nbsp; See my code below&lt;/SPAN&gt;&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;PRE&gt;data transactions;
input process_date :yymmdd10. amount reference &amp;amp;:$50.;
format process_date date9.;
datalines;
2022-02-14 100 trn01
2022-02-14 200 trn02
2022-02-15 300 trn03
2022-02-15 500 trn05
2022-02-15 500 trn05
;
PROC SQL;
   CREATE TABLE trns AS 
   SELECT * from transactions
;QUIT;

DATA final_data;                                                     
    SET trns;                                                
  if weekday(today())in (2,3) then if process_date=today()-4;                   
  else if weekday(today()) in (5,6) then if process_date=today()-2;
  else if weekday(today()) = 4 then if today()-4&amp;lt;=process_date&amp;lt;=today()-2;
RUN;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 09:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796817#M255719</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2022-02-17T09:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing Code/SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796823#M255725</link>
      <description>&lt;P&gt;Your first SQL does nothing except create an identical copy of the dataset, so discard it.&lt;/P&gt;
&lt;P&gt;It's a larger WHERE clause in SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where
  weekday(today()) in (2,3) and process_date = today() - 4
  or
  weekday(today()) in (5,6) and process_date = today() - 2
  or
  weekday(today()) = 4 and today() - 4 &amp;lt;= process_date &amp;lt;= today() - 2
  or
  weekday(today()) in (1,7)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last condition is needed, as you do not have a subsetting IF for those weekdays in your data step. You may need to expand this condition with regards to process_date.&lt;/P&gt;
&lt;P&gt;NEVER assume that your code will never be run on a weekend, it WILL happen one day. Believe me.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 09:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796823#M255725</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T09:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing Code/SAS Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796829#M255727</link>
      <description>&lt;P&gt;Hey &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, where would I be without you? Your solutions works like magic. I really appreciate it, God bless you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 10:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Optimizing-Code-SAS-Macro/m-p/796829#M255727</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2022-02-17T10:26:26Z</dc:date>
    </item>
  </channel>
</rss>

