<?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 do loop macro - how can I continue even though there is an error? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503768#M866</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is something like the following. It&amp;nbsp;is&amp;nbsp;a&amp;nbsp;simple do-loop, and inside the loop, there is a procedure, which generates an output for&amp;nbsp;each loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, the procedure often results in an error (ERROR: Floating Point Overflow. )&amp;nbsp;from a loop, and if the error is encountered, entire macro is stopped (ERROR: Termination due to Floating Point Exception). I want the macro to continue to proceed to the next loop when an error is resulted from from the&amp;nbsp;procedure of&amp;nbsp;a loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advise? Thank you in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;===============================================&lt;/SPAN&gt;&lt;BR /&gt;%macro xxx;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do i = 1 %to 10000.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set fq;&lt;/P&gt;&lt;P&gt;if _n_ = &amp;amp;i.;&lt;/P&gt;&lt;P&gt;call symput('cusip',cusip6);call symput('datadate',datadate);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc nlp data=datain(where = (cusip6 = "&amp;amp;cusip." and datadate = &amp;amp;datadate.))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out=dataout&amp;amp;i.;&lt;BR /&gt;.............&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;===============================================&lt;/P&gt;</description>
    <pubDate>Fri, 12 Oct 2018 16:00:02 GMT</pubDate>
    <dc:creator>mcjs</dc:creator>
    <dc:date>2018-10-12T16:00:02Z</dc:date>
    <item>
      <title>do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503768#M866</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is something like the following. It&amp;nbsp;is&amp;nbsp;a&amp;nbsp;simple do-loop, and inside the loop, there is a procedure, which generates an output for&amp;nbsp;each loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, the procedure often results in an error (ERROR: Floating Point Overflow. )&amp;nbsp;from a loop, and if the error is encountered, entire macro is stopped (ERROR: Termination due to Floating Point Exception). I want the macro to continue to proceed to the next loop when an error is resulted from from the&amp;nbsp;procedure of&amp;nbsp;a loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advise? Thank you in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;===============================================&lt;/SPAN&gt;&lt;BR /&gt;%macro xxx;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%do i = 1 %to 10000.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set fq;&lt;/P&gt;&lt;P&gt;if _n_ = &amp;amp;i.;&lt;/P&gt;&lt;P&gt;call symput('cusip',cusip6);call symput('datadate',datadate);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc nlp data=datain(where = (cusip6 = "&amp;amp;cusip." and datadate = &amp;amp;datadate.))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out=dataout&amp;amp;i.;&lt;BR /&gt;.............&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;===============================================&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503768#M866</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-12T16:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503772#M868</link>
      <description>&lt;P&gt;Please show an example of the error and its impact on the rest of the %DO loop.&lt;/P&gt;
&lt;P&gt;It shouldn't stop the macro, but perhaps it is setting the system option OBS to zero and this is making the other steps fail?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503772#M868</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-12T16:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503776#M869</link>
      <description>&lt;P&gt;The following is log from the error message. At the message, output dataset is PINEST&amp;amp;i. You can see that do-loop stopped at i=801.&lt;/P&gt;&lt;P&gt;I need the macro to proceed to i=802, ignoring the error and no-ouput of i=801.&amp;nbsp;&lt;/P&gt;&lt;P&gt;===================================&lt;/P&gt;&lt;P&gt;ERROR: Floating Point Overflow.&lt;BR /&gt;ERROR: Termination due to Floating Point Exception&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 64 observations read from the data set WORK.PIN_DATA.&lt;BR /&gt;WHERE (cusip6='006739 ') and (datadate=19996);&lt;BR /&gt;WARNING: The data set WORK.PINEST801 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 5 variables.&lt;BR /&gt;WARNING: Data set WORK.PINEST801 was not replaced because this step was stopped.&lt;BR /&gt;NOTE: PROCEDURE NLP used (Total process time):&lt;BR /&gt;real time 0.15 seconds&lt;BR /&gt;cpu time 0.12 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;===================================&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503776#M869</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-12T16:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503782#M871</link>
      <description>&lt;P&gt;Your problem does not come from macro code, but from proc nlp.&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="http://morgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/en/ormpug/59679/HTML/default/nlp_sect36.htm" target="_blank"&gt;http://morgan.dartmouth.edu/Docs/sas92/support.sas.com/documentation/cdl/en/ormpug/59679/HTML/default/nlp_sect36.htm&lt;/A&gt;&amp;nbsp;for a possible remedy.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503782#M871</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-12T16:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503813#M873</link>
      <description>&lt;P&gt;Hi KurtBremser,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is exactly why I coded a looping macro&amp;nbsp;by cusip and datadate, rather than "proc nlp...;by cusip datadate;..."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand&amp;nbsp;proc nlp returns error for some type of data. My question is, even when proc nlp returns an error, why the macro is not proceeding to the next loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 17:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/503813#M873</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-12T17:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504702#M997</link>
      <description>&lt;P&gt;The question is, does the macro loop stop immediately, or is it that the SAS session enters syntax check mode, and no further Base code is executed?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 13:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504702#M997</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T13:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504715#M1000</link>
      <description>&lt;P&gt;I am not sure what "&lt;SPAN&gt;syntax check mode" is, but I would like to answer it stops immediately. See the log below. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;===================================================&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;i = 21449: cusip6 = 829073 and datadate = 19358&lt;/P&gt;&lt;P&gt;NOTE: Your code contains 3 program statements.&lt;BR /&gt;NOTE: Gradient is computed using analytic formulas.&lt;BR /&gt;NOTE: Hessian is computed using analytic formulas.&lt;BR /&gt;ERROR: Floating Point Overflow.&lt;BR /&gt;ERROR: Termination due to Floating Point Exception&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 69 observations read from the data set WORK.PIN_DATA.&lt;BR /&gt;WHERE (cusip6='829073 ') and (datadate=19358);&lt;BR /&gt;WARNING: The data set PIN.PINEST21449 may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 5 variables.&lt;BR /&gt;NOTE: PROCEDURE NLP used (Total process time):&lt;BR /&gt;real time 0.18 seconds&lt;BR /&gt;cpu time 0.12 seconds&lt;/P&gt;&lt;P&gt;==============================================&lt;/P&gt;&lt;P&gt;This is the last a few lines of log&amp;nbsp;where the macro stops.&amp;nbsp;The first line of the above log is generated by a "%put" command. It shows that the loop stopped at i=21499, while the loop is supposed to run to i=26412.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 13:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504715#M1000</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-16T13:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504718#M1002</link>
      <description>&lt;P&gt;FYI, I am adding entire macro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;=================================&lt;/P&gt;&lt;P&gt;%macro pin(dsetin = , alpha = , from = , delta = , eta = , mu = );&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data _null_;set &amp;amp;dsetin. end = eof;if eof then call symput('num',_n_);run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%local i;&lt;BR /&gt;%do i = &amp;amp;from. %to &amp;amp;num.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;set &amp;amp;dsetin.;if _n_ = &amp;amp;i.;call symput('cusip',cusip6);call symput('datadate',datadate);run;&lt;/P&gt;&lt;P&gt;%put i = &amp;amp;i.: cusip6 = &amp;amp;cusip. and datadate = &amp;amp;datadate.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc nlp data=pin_data(where = (cusip6 = "&amp;amp;cusip." and datadate = &amp;amp;datadate.)) noprint&lt;BR /&gt;out=pin.pinest&amp;amp;i.(keep = cusip6 datadate ALPHA ETA MU);&lt;BR /&gt;by cusip6 datadate;&lt;BR /&gt;max loglik;&lt;BR /&gt;decvar ALPHA = &amp;amp;alpha., DELTA = &amp;amp;delta., ETA = &amp;amp;eta., MU = &amp;amp;mu.;&lt;BR /&gt;M = min(buys,sells) + max(buys,sells) / 2.0 ;&lt;BR /&gt;x = eta / (mu + eta) ;&lt;BR /&gt;bounds 0.0 &amp;lt; eta mu, 0.0 &amp;lt;= alpha delta &amp;lt;= 1.0 ;&lt;BR /&gt;loglik = -2.0 * eta + M * log(x) + (buys + sells) * log(mu + eta) +&lt;BR /&gt;log( alpha * (1.0 - delta) * exp(-1.0 * mu) * (x ** (sells - M )) +&lt;BR /&gt;alpha * delta * exp(-1.0 * mu) * (x ** (buys - M)) +&lt;BR /&gt;(1.0 - alpha) * (x ** (buys + sells - M)) ) ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if &amp;amp;i. = 1 %then %do;data pinest;set pinest1;run;%end;&lt;BR /&gt;%else %do;data pinest;set pinest pin.pinest&amp;amp;i.;run;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 13:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504718#M1002</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-16T13:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504730#M1007</link>
      <description>&lt;P&gt;OK, this is peculiar. The macro loop continued in all circumstances I could test with some deliberately crashing code.&lt;/P&gt;
&lt;P&gt;Quick and dirty:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro create_data;
%do i = 1 %to 3;
data work.class&amp;amp;i;
set sashelp.class;
run;
%end;
%mend;
%create_data
%macro test_data;
%do i = 1 %to 5;
%put i=&amp;amp;i.;
data want;
set work.class&amp;amp;i;
run;
%end;
%mend;
%test_data&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I tried several of the errorhandling system options, but the only thing I could come up with is an automatic abend (termination of the SAS process) when the error was encountered. In all other cases, the %do loop continued, and I received a further ERROR message in iteration 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would bring this to the attention of SAS technical support, maybe they know something I don't.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504730#M1007</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T14:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504737#M1009</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;SPAN&gt;KurtBremser. As you commented, maybe it's related to proc nlp. I will contact SAS.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504737#M1009</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-16T14:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504739#M1010</link>
      <description>Check the setting of the ERRORABEND option.&lt;BR /&gt;%put %sysfunc(getoption(errorabend));&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504739#M1010</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-16T14:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504740#M1011</link>
      <description>&lt;P&gt;See the log as follows:&lt;/P&gt;&lt;P&gt;========================================&lt;/P&gt;&lt;P&gt;899 %put %sysfunc(getoption(errorabend));&lt;BR /&gt;NOERRORABEND&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504740#M1011</guid>
      <dc:creator>mcjs</dc:creator>
      <dc:date>2018-10-16T14:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: do loop macro - how can I continue even though there is an error?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504741#M1012</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Check the setting of the ERRORABEND option.&lt;BR /&gt;%put %sysfunc(getoption(errorabend));&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That was one of my tests, but then the workspace server terminated with a proper final message in the log. A "simple" exit of the %do loop without any further messages, but a still living SAS process did not happen.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-loop-macro-how-can-I-continue-even-though-there-is-an-error/m-p/504741#M1012</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-16T14:48:51Z</dc:date>
    </item>
  </channel>
</rss>

