<?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: SAS Macro error with time function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98115#M20749</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, there are several issues in your code&lt;/P&gt;&lt;P&gt;1. Replace 'hour' with hour. In macro, you don't need to quote it.&lt;/P&gt;&lt;P&gt;2. Time() needed to be wrapped with %sysfunc()&lt;/P&gt;&lt;P&gt;3. This is not a problem, since you are NOT doing any arithmetic operations,&amp;nbsp; you don't need %eval to wrap up &amp;amp;i.&lt;/P&gt;&lt;P&gt;4. This is also not necessarily a problem, but you may want to add a format for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _createtimeintervals;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 24;&lt;/P&gt;&lt;P&gt;%let j = %eval( -&amp;amp;i.);&lt;/P&gt;&lt;P&gt;%put "i = &amp;amp;i. and j=&amp;amp;j.";&lt;/P&gt;&lt;P&gt;%let nexthr =%sysfunc(intnx(hour,%sysfunc(time()),&amp;amp;i.), time.);&lt;/P&gt;&lt;P&gt;%put "next hour = &amp;amp;nexthr.";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend _createtimeintervals;&lt;/P&gt;&lt;P&gt;%_createtimeintervals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Aug 2013 14:35:18 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2013-08-02T14:35:18Z</dc:date>
    <item>
      <title>SAS Macro error with time function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98114#M20748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to calculate the hourly time intervals for the past 24 hours using a loop. Can anyone help me with resolving the error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I rather use a datastep to acheive this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _createtimeintervals;&lt;BR /&gt;%do i = 1 %to 24;&lt;BR /&gt;%let j = %eval( -&amp;amp;i.);&lt;BR /&gt;%put "i = &amp;amp;i. and j=&amp;amp;j.";&lt;BR /&gt;%let nexthr =%sysfunc(intnx('hour',time(),%eval(&amp;amp;i.)));&lt;BR /&gt;%put "next hour = &amp;amp;nexthr.";&lt;BR /&gt;%end;&lt;BR /&gt;%mend _createtimeintervals;&lt;BR /&gt;%_createtimeintervals&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ERROR: Required operator not found in expression: time() &lt;BR /&gt;ERROR: Argument 2 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.&lt;BR /&gt;ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list.&amp;nbsp; Execution of %SYSCALL statement or %SYSFUNC &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or %QSYSFUNC function reference is terminated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;saspert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 14:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98114#M20748</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2013-08-02T14:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro error with time function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98115#M20749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, there are several issues in your code&lt;/P&gt;&lt;P&gt;1. Replace 'hour' with hour. In macro, you don't need to quote it.&lt;/P&gt;&lt;P&gt;2. Time() needed to be wrapped with %sysfunc()&lt;/P&gt;&lt;P&gt;3. This is not a problem, since you are NOT doing any arithmetic operations,&amp;nbsp; you don't need %eval to wrap up &amp;amp;i.&lt;/P&gt;&lt;P&gt;4. This is also not necessarily a problem, but you may want to add a format for your time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _createtimeintervals;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 24;&lt;/P&gt;&lt;P&gt;%let j = %eval( -&amp;amp;i.);&lt;/P&gt;&lt;P&gt;%put "i = &amp;amp;i. and j=&amp;amp;j.";&lt;/P&gt;&lt;P&gt;%let nexthr =%sysfunc(intnx(hour,%sysfunc(time()),&amp;amp;i.), time.);&lt;/P&gt;&lt;P&gt;%put "next hour = &amp;amp;nexthr.";&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend _createtimeintervals;&lt;/P&gt;&lt;P&gt;%_createtimeintervals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 14:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98115#M20749</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-08-02T14:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro error with time function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98116#M20750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;As far as I have been using %sysfunc with INTNX (and maybe there are better ways)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need a separate line in the code where time() is assigned to a macro variable, and in macro code, you don't put 'hour' in quotes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you don't need quotes in your %put statement and &amp;amp;j doesn't seem to play any useful role here, so the simplified and working macro should be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro _createtimeintervals;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 24;&lt;/P&gt;&lt;P&gt;%let abc=%sysfunc(time());&lt;/P&gt;&lt;P&gt;%let nexthr=%sysfunc(intnx(hour,&amp;amp;abc,&amp;amp;i));&lt;/P&gt;&lt;P&gt;%put nexthr &amp;amp;nexthr;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend _createtimeintervals;&lt;/P&gt;&lt;P&gt;%_createtimeintervals&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 14:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98116#M20750</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-08-02T14:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Macro error with time function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98117#M20751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want a single line of code, rather then two lines of code mentioned above, you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let nexthr=%sysfunc(intnx(hour,%sysfunc(time()),&amp;amp;i));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2013 14:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Macro-error-with-time-function/m-p/98117#M20751</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-08-02T14:37:36Z</dc:date>
    </item>
  </channel>
</rss>

