<?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: out of range warning and errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362491#M85646</link>
    <description>&lt;P&gt;Please post your full code.&lt;/P&gt;
&lt;P&gt;It is importnat to know what is the origin of each macro variable (how is it defined) and is it used correctly.&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2017 13:08:25 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-05-29T13:08:25Z</dc:date>
    <item>
      <title>out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362461#M85629</link>
      <description>&lt;P&gt;i am using the below code and get warnings for out of range and error message as below&lt;/P&gt;
&lt;P&gt;STUDY_START = datepart(&amp;amp;StudyStart.); *start date and end date is defined in the macro call and it is date9. format&lt;BR /&gt; STUDY_END = datepart(&amp;amp;StudyEnd.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if STUDY_START ne . and STUDY_END = . then do;&lt;BR /&gt; %let num = %sysfunc(countw(&amp;amp;timeinterval.,¤));&lt;BR /&gt; STUDY_END = STUDY_START + %scan(&amp;amp;timeinterval.,&amp;amp;num.,¤);&lt;BR /&gt; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WARNING: Argument 2 to macro function %SCAN is out of range.&lt;BR /&gt;NOTE 137-205: Line generated by the invoked macro "AE_INCPREV_TEST".&lt;BR /&gt;31 STUDY_END = STUDY_START + %scan(&amp;amp;timeinterval.,&amp;amp;num.,¤); end; if STUDY_START ne&lt;BR /&gt; -&lt;BR /&gt; 22&lt;BR /&gt;31 ! . and STUDY_END ne . then TimeStudy = (STUDY_END - STUDY_START) + 1; if TimeStudy ne .&lt;BR /&gt;31 ! and &amp;amp;AnlVar. ne ' ' then do; tmp_ASTDT = datepart(ASTDT); tmp_AENDT =&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,&lt;BR /&gt; a numeric constant, a datetime constant, a missing value, INPUT, PUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not able to figure out what the error and warning is it about.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 10:55:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362461#M85629</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-05-29T10:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362473#M85635</link>
      <description>&lt;P&gt;You are mixing datastep statements with macro programing statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you are using a datastep (in &amp;nbsp;amacro program) then change your code to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
       STUDY_START = datepart(&amp;amp;StudyStart.);
       STUDY_END = datepart(&amp;amp;StudyEnd.);

      if STUDY_START ne . and STUDY_END = . then 
         num = countw("&amp;amp;timeinterval",'¤');
         STUDY_END = STUDY_START + scan("&amp;amp;timeinterval",num,'¤'); /* excess dot after num was removed */
     end;
     .......... etc. ...........
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2017 13:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362473#M85635</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-29T13:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362474#M85636</link>
      <description>You cannot use %LET as part of IF statement.</description>
      <pubDate>Mon, 29 May 2017 11:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362474#M85636</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-29T11:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362477#M85638</link>
      <description>&lt;P&gt;Thanks for the solution. Now i get another error asking for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable TIMEINTERVAL resolves to&lt;BR /&gt;ERROR: The name ¤ is not a valid SAS name.&lt;BR /&gt;MPRINT(AE_INCPREV_TEST): num = countw(,¤);&lt;BR /&gt;ERROR: The name ¤ is not a valid SAS name.&lt;BR /&gt;SYMBOLGEN: Macro variable TIMEINTERVAL resolves to&lt;BR /&gt;ERROR: The name ¤ is not a valid SAS name.&lt;BR /&gt;MPRINT(AE_INCPREV_TEST): STUDY_END = STUDY_START + scan(,num,¤);&lt;BR /&gt;ERROR: The name ¤ is not a valid SAS name.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 11:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362477#M85638</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2017-05-29T11:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362491#M85646</link>
      <description>&lt;P&gt;Please post your full code.&lt;/P&gt;
&lt;P&gt;It is importnat to know what is the origin of each macro variable (how is it defined) and is it used correctly.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 13:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362491#M85646</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-29T13:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: out of range warning and errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362510#M85650</link>
      <description>&lt;P&gt;We need the code&amp;amp;log, the whole code&amp;amp;log, and nothing but the code&amp;amp;log.&lt;/P&gt;
&lt;P&gt;Assume you are before one of those beloved American courts in a TV series.&lt;/P&gt;
&lt;P&gt;Just replace "truth" with "code and log".&lt;/P&gt;
&lt;P&gt;The error messages without the respective code are UTTERLY, TOTALLY useless.&lt;/P&gt;
&lt;P&gt;And post the log in a {i} window, so that the horizontal positioning of the messages is preserved.&lt;/P&gt;
&lt;P&gt;Help us in helping you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for macro programming:&lt;/P&gt;
&lt;P&gt;- write the Base SAS code so that it works&lt;/P&gt;
&lt;P&gt;- replace code that needs to be dynamic with a macro variable, set the macro variable, and make sure that the code runs&lt;/P&gt;
&lt;P&gt;- then, and only then, wrap the code into a macro with parameters&lt;/P&gt;
&lt;P&gt;- before using macro logic in combination with Base SAS code, make sure through using %put statements that the macro evaluations work as expected; only then make the Base SAS code within the macro active.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NEVER write the whole shebang in one sweep, because then you end up where you are now. Clueless.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 14:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/out-of-range-warning-and-errors/m-p/362510#M85650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-29T14:34:16Z</dc:date>
    </item>
  </channel>
</rss>

