<?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: Running a Macro for a control table of dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299685#M63236</link>
    <description>&lt;P&gt;Why do you need a separate table of working days?&amp;nbsp; Would&amp;nbsp; your shipping log ever contain dates that are weekends or holidays?&amp;nbsp; If it did, would you want to ignore them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It certainly seems like this could be done in one step, rather than repeating one step per day.&amp;nbsp; But we'll get to that later.&amp;nbsp; First, what's in the shipping log?&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2016 20:47:10 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-09-20T20:47:10Z</dc:date>
    <item>
      <title>Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299673#M63233</link>
      <description>&lt;P&gt;I'm trying to run a macro that gives counts of widgets by date. The macro give me a count of scheduled deliverables and a count of acutal deliverables for a given day.&amp;nbsp; I want to loop through this macro "N" times, based on the dates that are in a separate table.&amp;nbsp; This table would contain dates for the year that are work days, excluding holidays and weekends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ultimately, I'd like to set up the date table such that I have dates for the next few years, and set the code so that it controls for when the date in the control table doesn't exceed the current date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the macro as it currently stands:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro takt(rptdate);&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;create table takt_data as&lt;BR /&gt;&amp;nbsp;select "&amp;amp;rptdate" as report_date,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(ship_date = input("&amp;amp;rptdate",mmddyy10.)) as actual,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum(contract_date = input("&amp;amp;rptdate",mmddyy10.)) as planned,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;calculated actual / calculated planned as takt_index&lt;BR /&gt;&amp;nbsp;from shippinglog&lt;BR /&gt;&amp;nbsp;where substr(project,1,2) &amp;lt;&amp;gt; "CD"&lt;BR /&gt;&amp;nbsp;;&lt;BR /&gt;quit;&lt;BR /&gt;proc append base = takt data = takt_data force;&lt;BR /&gt;quit;&lt;BR /&gt;%mend takt;&lt;BR /&gt;%takt(09/01/2016);&lt;BR /&gt;%takt(09/02/2016);&lt;BR /&gt;%takt(09/05/2016);&lt;BR /&gt;%takt(09/06/2016);&lt;BR /&gt;%takt(09/07/2016);&lt;BR /&gt;%takt(09/08/2016);&lt;BR /&gt;%takt(09/09/2016);&lt;BR /&gt;%takt(09/12/2016);&lt;BR /&gt;%takt(09/13/2016);&lt;BR /&gt;%takt(09/14/2016);&lt;BR /&gt;%takt(09/15/2016);&lt;BR /&gt;%takt(09/16/2016);&lt;BR /&gt;%takt(09/19/2016);&lt;BR /&gt;%takt(09/20/2016);&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299673#M63233</guid>
      <dc:creator>chimanbj</dc:creator>
      <dc:date>2016-09-20T20:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299685#M63236</link>
      <description>&lt;P&gt;Why do you need a separate table of working days?&amp;nbsp; Would&amp;nbsp; your shipping log ever contain dates that are weekends or holidays?&amp;nbsp; If it did, would you want to ignore them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It certainly seems like this could be done in one step, rather than repeating one step per day.&amp;nbsp; But we'll get to that later.&amp;nbsp; First, what's in the shipping log?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299685#M63236</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-20T20:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299688#M63238</link>
      <description>The shipping log is a contains a list of projects that have been delivered, as well as projects that are currently being worked on. I need to be able to see weekdays where no date occurred.  I'm looking at two date fields, ship_date (actual deliveries) and contract_date (expected deliveries).  There are some dates where I don't have an actual or expected.  Those dates need to be tracked in my report as well as the dates where we have activity.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299688#M63238</guid>
      <dc:creator>chimanbj</dc:creator>
      <dc:date>2016-09-20T20:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299692#M63241</link>
      <description>&lt;P&gt;Basically you should provide some sample data, not necessarily real, that mimics your actual data and expected results. Then we can help with suggesting methods that may work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299692#M63241</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-20T20:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299693#M63242</link>
      <description>&lt;P&gt;OK, so one plan would be to use the shipping log just once.&amp;nbsp; No macros involved.&amp;nbsp; Get a summary for each day in the shipping log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having done that, merge it with your list of days of interest.&amp;nbsp; As part of that step, you can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Remove any shipping dates that are not on your list of dates.&lt;/LI&gt;
&lt;LI&gt;Set summary variables to 0 for dates that are not in your shipping log.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 20 Sep 2016 20:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299693#M63242</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-20T20:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299698#M63243</link>
      <description>&lt;P&gt;Run a proc freq of contract vs actual date -&amp;gt; save to a dataset&lt;/P&gt;
&lt;P&gt;Keep only records where contract = actual date (where actual_date=contract_date)&lt;/P&gt;
&lt;P&gt;These will be your % takt_index&lt;/P&gt;
&lt;P&gt;1- values is missed&lt;/P&gt;
&lt;P&gt;Check the percent values for the one that matches your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=have noprint;&lt;/P&gt;
&lt;P&gt;table ship_date*contract_date/out=delivery (where=(ship_date=contract_date)) outpct;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 21:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299698#M63243</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-20T21:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Running a Macro for a control table of dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299704#M63245</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16697"&gt;@chimanbj&lt;/a&gt; wrote:&lt;BR /&gt;The shipping log is a contains a list of projects that have been delivered, as well as projects that are currently being worked on. I need to be able to see weekdays where no date occurred. I'm looking at two date fields, ship_date (actual deliveries) and contract_date (expected deliveries). There are some dates where I don't have an actual or expected. Those dates need to be tracked in my report as well as the dates where we have activity.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sounds almost like Select distinct from the shipping log and compare the control data set except the dates in that distinct list. Below the code has a distict set of shipping log dates and compared with those in a control set. If you have a specific product requirement then including that with the selects would work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data shippinglog;
   informat x mmddyy10.;
   format x mmddyy10.;
   input x;
datalines;
05/15/2016
05/16/2016
05/17/2016
05/18/2016
05/20/2016
;
run;

Data control ;
   informat x mmddyy10.;
   format x mmddyy10.;
   input x;
datalines;
05/15/2016
05/16/2016
05/17/2016
05/18/2016
05/19/2016
05/20/2016
;
run;

proc sql;
   select x from control
   except
   select x from shippinglog;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second select might even be" select distinct x from fullshippinglog;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The results are the ones in Control that are NOT in the shipping log.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 22:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-Macro-for-a-control-table-of-dates/m-p/299704#M63245</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-20T22:14:51Z</dc:date>
    </item>
  </channel>
</rss>

