<?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: Macros and Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47037#M9712</link>
    <description>If appropriate, the %SLEEP macro can be eliminated by using:&lt;BR /&gt;
&lt;BR /&gt;
%LET X = %SYSFUNC(SLEEP(60));&lt;BR /&gt;
&lt;BR /&gt;
Also, if you only need to detect the presence of at least one obs for the current date, consider using a WHERE and also have a DO/END loop to invoke the SYMPUT, along with a STOP; statement -- given what you have shown for a DATA step invocation, there is really no need to pass the entire file, right?  Just a thought for SAS programming optimization.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Fri, 19 Jun 2009 13:44:42 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-06-19T13:44:42Z</dc:date>
    <item>
      <title>Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47034#M9709</link>
      <description>I am trying to write a macro that checks a table every 60 seconds to see if there is an entry for today's date.  If not, it sleeps 60 seconds, if found, it starts a process.  I think I have two problems:  not sure if I am using Call Symput correctly, and the &amp;amp;sysdate is character, and I am trying to compare to a date (numberic) value.  Any help would be greatly appreciated!&lt;BR /&gt;
&lt;BR /&gt;
%MACRO AUTO();&lt;BR /&gt;
%LET WAIT = 'TRUE';&lt;BR /&gt;
%DO %WHILE (&amp;amp;WAIT = 'TRUE');&lt;BR /&gt;
	%SLEEP(60);&lt;BR /&gt;
	DATA _NULL_;&lt;BR /&gt;
		SET FILES.CHECK;&lt;BR /&gt;
		IF DATE = "&amp;amp;SYSDATE" THEN CALL SYMPUT('WAIT', 'FALSE');&lt;BR /&gt;
	RUN;&lt;BR /&gt;
%END;&lt;BR /&gt;
/*PROCESS*/&lt;BR /&gt;
%MEND AUTO;</description>
      <pubDate>Fri, 19 Jun 2009 13:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47034#M9709</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2009-06-19T13:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47035#M9710</link>
      <description>There is no %SLEEP macro, unless you have defined it, possibly to use a DATA step with SLEEP function?  You may want to explore the use of %SYSFUNC and invoking a CALL function in that manner without a DATA step.&lt;BR /&gt;
&lt;BR /&gt;
Also the &amp;amp;SYSDATE value (in double-quotes) must be identified as a SAS DATE constant by adding the "D" suffix to the quoted string.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 19 Jun 2009 13:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47035#M9710</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-19T13:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47036#M9711</link>
      <description>Thank you so much!  I have a sleep macro, but I had completely forgotten to use the d to make sysdate a data constant.  Works great now.  I included the working code below in case it helps anyone else.&lt;BR /&gt;
&lt;BR /&gt;
%MACRO AUTO();&lt;BR /&gt;
%LET WAIT = 'TRUE';&lt;BR /&gt;
%DO %WHILE (&amp;amp;WAIT = 'TRUE');&lt;BR /&gt;
	%SLEEP(2);&lt;BR /&gt;
	DATA _NULL_;&lt;BR /&gt;
		SET FILES.CHECK;&lt;BR /&gt;
		IF DATE = "&amp;amp;SYSDATE"D THEN CALL SYMPUT('WAIT', 'FALSE');&lt;BR /&gt;
	RUN;&lt;BR /&gt;
%END;&lt;BR /&gt;
/*PROCESS*/&lt;BR /&gt;
%PUT "IT WORKED!";&lt;BR /&gt;
%MEND AUTO;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO SLEEP(SECONDS);&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
Var1 = SLEEP(&amp;amp;SECONDS);&lt;BR /&gt;
RUN;&lt;BR /&gt;
%MEND SLEEP;</description>
      <pubDate>Fri, 19 Jun 2009 13:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47036#M9711</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2009-06-19T13:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47037#M9712</link>
      <description>If appropriate, the %SLEEP macro can be eliminated by using:&lt;BR /&gt;
&lt;BR /&gt;
%LET X = %SYSFUNC(SLEEP(60));&lt;BR /&gt;
&lt;BR /&gt;
Also, if you only need to detect the presence of at least one obs for the current date, consider using a WHERE and also have a DO/END loop to invoke the SYMPUT, along with a STOP; statement -- given what you have shown for a DATA step invocation, there is really no need to pass the entire file, right?  Just a thought for SAS programming optimization.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 19 Jun 2009 13:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47037#M9712</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-19T13:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47038#M9713</link>
      <description>Also, you should consider working with the lock table features.&lt;BR /&gt;
&lt;BR /&gt;
If any process tries to write something, while you checking (reading) the table, or you try to check the table while its being written to, you'll get an error (unless it's a SAS/SHARE library or, your SO is able to do the lock handling, like z/OS).&lt;BR /&gt;
&lt;BR /&gt;
See the online documentation:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/shrref/59595/HTML/default/a000203947.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/shrref/59595/HTML/default/a000203947.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Fri, 19 Jun 2009 14:44:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47038#M9713</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-06-19T14:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47039#M9714</link>
      <description>Thanks.  I had just run into that problem!</description>
      <pubDate>Fri, 19 Jun 2009 14:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47039#M9714</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2009-06-19T14:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47040#M9715</link>
      <description>Great tips.  I replaced the sleep function, and the where statement really helped.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Fri, 19 Jun 2009 14:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47040#M9715</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2009-06-19T14:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47041#M9716</link>
      <description>I have one more question if you don't mind.  I am calling the macro with the following parameters, and it works great:&lt;BR /&gt;
&lt;BR /&gt;
%LET CURR = "&amp;amp;SYSDATE"D - 1;&lt;BR /&gt;
%LET PREV = "&amp;amp;SYSDATE"D - 2;&lt;BR /&gt;
&lt;BR /&gt;
How do I get the date one month prior (i.e. 6/19/09 and 5/19/09), since the number of days to subtract will vary?</description>
      <pubDate>Fri, 19 Jun 2009 15:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47041#M9716</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2009-06-19T15:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47042#M9717</link>
      <description>If you intend to do it macro-based, you will need to work with %SYSFUNC and look at the DATE-related functions (normally used in a DATA step but accessible in macro language when using SYSFUNC.  Then construct a new macro variable, again using SYSFUNC, and the MDY function.&lt;BR /&gt;
&lt;BR /&gt;
Suggest in the future you consider creating a new post for a new question or discussion topic.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 19 Jun 2009 15:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47042#M9717</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-06-19T15:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47043#M9718</link>
      <description>the INTNX() function has a SAMEDAY parameter (in place of begin/end/middle) &lt;BR /&gt;
&lt;BR /&gt;
%put %sysfunc( intnx( month, "21Jun2009"d, -1, sameday ),date9 ) ;&lt;BR /&gt;
should report 21May2009 in the log&lt;BR /&gt;
 (works for me)&lt;BR /&gt;
PeterC</description>
      <pubDate>Sat, 20 Jun 2009 17:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47043#M9718</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-06-20T17:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macros and Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47044#M9719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very nice to know about SAMEDAY parameter in intnx function. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Feb 2012 17:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macros-and-Dates/m-p/47044#M9719</guid>
      <dc:creator>Augusto</dc:creator>
      <dc:date>2012-02-29T17:01:32Z</dc:date>
    </item>
  </channel>
</rss>

