Date: Mon, 1 Oct 2001 15:42:17 -0500
Reply-To: Paul Thompson <paul@WUBIOS.WUSTL.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Thompson <paul@WUBIOS.WUSTL.EDU>
Organization: Washington University in St. Louis
Subject: Re: VALUE
Content-Type: text/html; charset=us-ascii
<html>
<head>
</head>
<body>
<br>
<br>
Dale McLerran wrote:<br>
<blockquote type="cite" cite="mid:200110012003.NAA03409@mail9.bigmailbox.com">
<pre wrap="">Dale McLerran wrote:<br><br></pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Paul,I sometimes use a GOTO statement. Consider the situation in<br>which there is a very complex (long) program that requires<br>specification of certain inputs right from the start. If those<br>inputs are not present, then we will terminate the program (with<br>appropriate message to inform the user why the program did not run).<br>Otherwise,we may have hundreds of lines of code which are executed.<br>Now, if the main code block is hundreds of lines long, I don't think<br>that should be buried in an ELSE DO block. A GOTO allows one to<br>branch out of the program without executing the main code block and<br>without burying the main code block in an ELSE DO block. So,I use<br>GOTO (typically when constructing a macro) in the following way:<br><br>%macro xyz(<list of inputs>);<br>%if <check on inputs indicates problem> %then %do;<br> %put Failed to specify ...;<br> %goto endmac;<br>%end;<br><br><major code block goes here><br><br>%:
endmac;<br>%mend xyz;<br><br>Defensible? I certainly think so. How would you handle this?<br></pre>
</blockquote>
</blockquote>
<pre wrap=""><!----><br><br>To which Paul Thompson replied:<br></pre>
<blockquote type="cite">
<pre wrap="">me, I bury it in an %ELSE %DO block. I try to work with careful<br>indenting. I would like SAS to implement labeled %END statements,<br>which would greatly help.<br><br>At least with an %DO-%END, you know where you are going. At least I<br>do, usually.<br><br>If it gets that confusing, I make the code into a new macro, remove<br>the code to somewhere else and then it is much clearer. Sounds like<br>you could do the same. Get rid of those pesky GOTOs, to boot :-><br></pre>
</blockquote>
<pre wrap=""><!----><br><br>No, I don't want to place my code in another program. That sort of<br>proliferation just gets confusing, much more so than a simple GOTO<br>the end of the program because the inputs were not available. I<br>believe that the style which I presented is easy to trace the logic<br>of, it does not require the main program to be embedded in an ELSE<br>DO structure when the code is long, and it does not proliferate<br>programs. You certainly can code the way in which you are<br>comfortable, but do you really believe that the GOTO structure here<br>is not clean? If that is what you believe, then one simple question:<br>Why?<br></pre>
</blockquote>
I just don't like it. This is much cleaner, IMHO. All in the same file,
if that makes any difference.<br>
<br>
%macro _maca;<br>
6000 lines of code<br>
%mend _maca;<br>
<br>
%macro _macb;<br>
6000 lines of code<br>
%mend;<br>
<br>
%macro _overrun;<br>
%if (&_a=1) %then %do;<br>
%_maca;<br>
%end;<br>
%else %do;<br>
%_macb;<br>
%end;<br>
%mend _overrun;<br>
<br>
I consider that to be clean, clear and easy to follow. It solves your problem
of separating logic from code. The code to be executed when &_a=1 is
clear. You are suggesting that putting 12000 lines of code together and adding
a GOTO makes it clearer? We are all entitled to whatever opinion we wish,
of course. <br>
<br>
Most of the code which has been proferred to date defending GOTOs are either
thouroughly opaque, poorly coded to lean toward GOTOs or simply silly, IMHO.
It's a matter of taste, when it comes down to the %end. I'm not convinced
by any of these examples.
<blockquote type="cite" cite="mid:200110012003.NAA03409@mail9.bigmailbox.com">
<pre wrap=""><br>Dale<br><br><br><br><br>---------------------------------------<br>Dale McLerran<br>Fred Hutchinson Cancer Research Center<br>mailto: <a class="moz-txt-link-abbreviated" href="mailto:dmclerra@fhcrc.org">dmclerra@fhcrc.org</a><br>Ph: (206) 667-2926<br>Fax: (206) 667-5977<br>---------------------------------------<br><br>------------------------------------------------------------<br>--== Sent via Deja.com ==--<br><a class="moz-txt-link-freetext" href="http://www.deja.com/">http://www.deja.com/</a><br></pre>
</blockquote>
<br>
</body>
</html>
|