<?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: stop executing sas after certain datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585837#M167162</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275095"&gt;@meckarthik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, need help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;currently got a program that should stop execute if it is Friday after 4 pm&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below macro get todays datetime&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;picture dtStamp (round)&lt;BR /&gt;low - high = '%Y-%0m-%0d %0H:%0M' (datatype=datetime);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let dttime = %sysfunc(datetime(), dtStamp.);&lt;/P&gt;
&lt;P&gt;%put &amp;amp;dttime;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code i tried to run but getting error .&lt;/P&gt;
&lt;P&gt;%macro controlit ;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;dttime &amp;lt;=6 and timepart(datetime())&amp;gt;'16:00't %then %do ;&lt;BR /&gt;stop ;&lt;BR /&gt;run ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend;&lt;BR /&gt;%controlit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help, please&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I answered this here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/stop-processing-code-if-a-certain-condition-is-met/m-p/581374" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/New-SAS-User/stop-processing-code-if-a-certain-condition-is-met/m-p/581374&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2019 14:31:14 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-09-03T14:31:14Z</dc:date>
    <item>
      <title>stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585835#M167161</link>
      <description>&lt;P&gt;Hi, need help&amp;nbsp;&lt;/P&gt;&lt;P&gt;currently got a program that should stop execute if it is Friday after 4 pm&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below macro get todays datetime&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;picture dtStamp (round)&lt;BR /&gt;low - high = '%Y-%0m-%0d %0H:%0M' (datatype=datetime);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%let dttime = %sysfunc(datetime(), dtStamp.);&lt;/P&gt;&lt;P&gt;%put &amp;amp;dttime;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code i tried to run but getting error .&lt;/P&gt;&lt;P&gt;%macro controlit ;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dttime &amp;lt;=6 and timepart(datetime())&amp;gt;'16:00't %then %do ;&lt;BR /&gt;stop ;&lt;BR /&gt;run ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend;&lt;BR /&gt;%controlit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help, please&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 14:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585835#M167161</guid>
      <dc:creator>meckarthik</dc:creator>
      <dc:date>2019-09-03T14:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585837#M167162</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275095"&gt;@meckarthik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, need help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;currently got a program that should stop execute if it is Friday after 4 pm&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below macro get todays datetime&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;picture dtStamp (round)&lt;BR /&gt;low - high = '%Y-%0m-%0d %0H:%0M' (datatype=datetime);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let dttime = %sysfunc(datetime(), dtStamp.);&lt;/P&gt;
&lt;P&gt;%put &amp;amp;dttime;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code i tried to run but getting error .&lt;/P&gt;
&lt;P&gt;%macro controlit ;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;dttime &amp;lt;=6 and timepart(datetime())&amp;gt;'16:00't %then %do ;&lt;BR /&gt;stop ;&lt;BR /&gt;run ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend;&lt;BR /&gt;%controlit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help, please&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I answered this here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/New-SAS-User/stop-processing-code-if-a-certain-condition-is-met/m-p/581374" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/New-SAS-User/stop-processing-code-if-a-certain-condition-is-met/m-p/581374&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 14:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585837#M167162</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-03T14:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585840#M167164</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275095"&gt;@meckarthik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, need help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;currently got a program that should stop execute if it is Friday after 4 pm&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below macro get todays datetime&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;picture dtStamp (round)&lt;BR /&gt;low - high = '%Y-%0m-%0d %0H:%0M' (datatype=datetime);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%let dttime = %sysfunc(datetime(), dtStamp.);&lt;/P&gt;
&lt;P&gt;%put &amp;amp;dttime;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the code i tried to run but getting error .&lt;/P&gt;
&lt;P&gt;%macro controlit ;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;dttime &amp;lt;=6 and timepart(datetime())&amp;gt;'16:00't %then %do ;&lt;BR /&gt;stop ;&lt;BR /&gt;run ;&lt;BR /&gt;%end ;&lt;BR /&gt;%mend;&lt;BR /&gt;%controlit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help, please&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since your macro includes a RUN statement I have to assume (because you did not show how your are actually calling the macro) that it is in a data step. Don't bother, just put that code equivalent in the data step. There are some serious issues related to data step compilation and macro resolutions. And your macro is likely not executing when you think it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what values do your created &amp;amp;dttime actually take? Look at them. Then compare those "values" to 6. Very carefully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have run this code and gotten an error you should post the log with the code and error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With macro's it is best to set the system option MPRINT when testing to get a better look at the code actually generated by the macro. Read the LOG carefully.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 14:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585840#M167164</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-03T14:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585875#M167179</link>
      <description>&lt;P&gt;This can never work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;dttime &amp;lt;=6 and timepart(datetime())&amp;gt;'16:00't %then %do ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In macro statements, you always need %sysfunc() to use data step functions. So you need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(timepart(%sysfunc(datetime())))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You also get an ERROR because the formatted datetime value cannot be compared to a number. Mind that a datetime value less than 6 is every point in time before 1960-01-01T00:00:06. Datetimes are counts of seconds from midnight on that day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To achieve a conditional stop, you don't need macro code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.class;
put name=;
if weekday(today()) = 6 and time() &amp;gt; '16:00't then stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 73         data _null_;
 74         set sashelp.class;
 75         put name=;
 76         if weekday(today()) = 6 and time() &amp;gt; '16:00't then stop;
 77         run;
 
 Name=Alfred
 Name=Alice
 Name=Barbara
 Name=Carol
 Name=Henry
 Name=James
 Name=Jane
 Name=Janet
 Name=Jeffrey
 Name=John
 Name=Joyce
 Name=Judy
 Name=Louise
 Name=Mary
 Name=Philip
 Name=Robert
 Name=Ronald
 Name=Thomas
 Name=William&lt;/PRE&gt;
&lt;P&gt;I changed it to work for today (a Tuesday):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.class;
put name=;
if weekday(today()) = 3 and time() &amp;gt; '16:00't then stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got this log:&lt;/P&gt;
&lt;PRE&gt; 73         data _null_;
 74         set sashelp.class;
 75         put name=;
 76         if weekday(today()) = 3 and time() &amp;gt; '16:00't then stop;
 77         run;
 
 Name=Alfred
 NOTE: There were 1 observations read from the data set SASHELP.CLASS.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.01 seconds
       cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Sep 2019 16:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/585875#M167179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-03T16:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/586037#M167245</link>
      <description>&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 09:54:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/586037#M167245</guid>
      <dc:creator>meckarthik</dc:creator>
      <dc:date>2019-09-04T09:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: stop executing sas after certain datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/586038#M167246</link>
      <description>&lt;P&gt;thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 09:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/stop-executing-sas-after-certain-datetime/m-p/586038#M167246</guid>
      <dc:creator>meckarthik</dc:creator>
      <dc:date>2019-09-04T09:55:15Z</dc:date>
    </item>
  </channel>
</rss>

