<?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: Schedule Script to Run on Day of Month, Time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806062#M317547</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187116"&gt;@calger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;We use SAS Enterprise Guide and I was told by my sadistic supervisor that it needs to coded.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sadistic. Only an idiot.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 14:09:01 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-04-05T14:09:01Z</dc:date>
    <item>
      <title>Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805920#M317488</link>
      <description>&lt;P&gt;Hello, I am new to SAS shell scripting. I've been tasked to run a piece of code and a macro on the 5th, 6th, and 7th day of each month. If it is the 5th, 6th, or 7th, the code should be run at 9AM. I have figured out what I think is an easy way for running the script on the correct dates. I am less sure about running it at the correct time (9AM). I've thought of doing this the same way as the date, but I'm worried that this method might not be resource efficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%let&lt;/FONT&gt; currentDT = &lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(datetime());&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#0000FF"&gt;%let&lt;/FONT&gt; currentDate = &lt;FONT color="#0000FF"&gt;%sysfunc&lt;/FONT&gt;(today());&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt; check_for_errors(pgm_name);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt; check_for_errors;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; &lt;/FONT&gt;&lt;FONT color="#0000FF"&gt;_null_&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; DOM = &lt;FONT color="#800080"&gt;"&amp;amp;currentDate"&lt;/FONT&gt; - intnx(&lt;FONT color="#800080"&gt;'month'&lt;/FONT&gt;, &lt;FONT color="#800080"&gt;"&amp;amp;currentDate"&lt;/FONT&gt;, &lt;FONT color="#008080"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/FONT&gt;)+&lt;FONT color="#008080"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;if&lt;/FONT&gt; DOM in (&lt;FONT color="#008080"&gt;&lt;STRONG&gt;5&lt;/STRONG&gt;&lt;/FONT&gt;,&lt;FONT color="#008080"&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;&lt;/FONT&gt;,&lt;FONT color="#008080"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/FONT&gt;) &lt;FONT color="#0000FF"&gt;then do&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;call&lt;/FONT&gt; execute (&lt;FONT color="#800080"&gt;'%include "/script_directory/script_name.sas";'&lt;/FONT&gt;);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;call&lt;/FONT&gt; execute (&lt;FONT color="#800080"&gt;'%check_for_errors("script_name.sas");'&lt;/FONT&gt;);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;end&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;else&lt;/FONT&gt;;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#000080"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 19:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805920#M317488</guid>
      <dc:creator>calger</dc:creator>
      <dc:date>2022-04-04T19:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805923#M317491</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DOM = "&amp;amp;currentDate" - intnx('month', "&amp;amp;currentDate", 0)+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you put quotes around your macro variables as you showed, I think you get an error because your code tries to subtract a missing numeric (that's what you will get from INTNX as you have written it) from a character string "&amp;amp;currentdate". Can't subtract anything from a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this should use the DAY function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DOM = day(&amp;amp;currentdate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and later&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if DOM in (5,6,7) and hour(&amp;amp;currentDT)=9 then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as "&lt;SPAN&gt;I'm worried that this method might not be resource efficient", why do you think that? What is your concern?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;UPDATE: I agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; 's suggestion to use built in scheduling tools rather than write this yourself.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 20:59:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805923#M317491</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-04T20:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805925#M317492</link>
      <description>&lt;P&gt;Its a lot easier to run SAS using a scheduling tool rather than programming your own scheduling in SAS itself. Your SAS appears to run on Unix which provides cron for scheduling. Alternatively you can use SAS Management Console which provides a point-and-click interface to scheduling, amongst other capabilities.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 19:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/805925#M317492</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-04-04T19:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806050#M317539</link>
      <description>We use SAS Enterprise Guide and I was told by my sadistic supervisor that it needs to coded.</description>
      <pubDate>Tue, 05 Apr 2022 13:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806050#M317539</guid>
      <dc:creator>calger</dc:creator>
      <dc:date>2022-04-05T13:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806051#M317540</link>
      <description>I cannot do that, I was told to code it.</description>
      <pubDate>Tue, 05 Apr 2022 13:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806051#M317540</guid>
      <dc:creator>calger</dc:creator>
      <dc:date>2022-04-05T13:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806054#M317543</link>
      <description>&lt;P&gt;&lt;CODE&gt;and hour(&amp;amp;currentDT)=9 then do;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Wouldn't this make the program run as many times as it is... I'm not sure how to word it. If SAS EG "reads" this program multiple times between 9 and 10, wouldn't it run it multiple times?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 13:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806054#M317543</guid>
      <dc:creator>calger</dc:creator>
      <dc:date>2022-04-05T13:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Schedule Script to Run on Day of Month, Time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806062#M317547</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/187116"&gt;@calger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;We use SAS Enterprise Guide and I was told by my sadistic supervisor that it needs to coded.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sadistic. Only an idiot.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 14:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Schedule-Script-to-Run-on-Day-of-Month-Time/m-p/806062#M317547</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-05T14:09:01Z</dc:date>
    </item>
  </channel>
</rss>

