LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 1 Oct 2001 13:50:06 -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:200110011809.LAA22751@mail9.bigmailbox.com"> <pre wrap="">Paul,<br><br>I sometimes use a GOTO statement. Consider the situation in which<br>there is a very complex (long) program that requires specification<br>of certain inputs right from the start. If those inputs are not<br>present, then we will terminate the program (with appropriate<br>message to inform the user why the program did not run). Otherwise,<br>we may have hundreds of lines of code which are executed.<br><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<br>and without burying the main code block in an ELSE DO block. So,<br>I use GOTO (typically when constructing a macro) in the following<br>way:<br><br></pre> </blockquote> me, I bury it in an %ELSE %DO block. &nbsp;I try to work with careful indenting. &nbsp;I would like SAS to implement labeled %END statements, which would greatly help. &nbsp;<br> <br> At least with an %DO-%END, you know where you are going. &nbsp;At least I do, usually.<br> <br> If it gets that confusing, I make the code into a new macro, remove the code to somewhere else and then it is much clearer. &nbsp;Sounds like you could do the same. &nbsp;Get rid of those pesky GOTOs, to boot :-&gt;<br> <br> My normal coding technique is to write everything inside macros anyway. &nbsp;For instance, here is my generic code structure:<br> <br> %macro _overrun(_bs=1,_es=2);<br> %if (&amp;_bs &lt;= 1 &amp; 1 &lt;= &amp;_es) %then %do;<br> 6000 lines of code<br> %end;<br> %if (&amp;_bs &lt;= 2 &amp; 2 &lt;= &amp;_es) %then %do;<br> 6000 lines of code<br> %end;<br> %mend _overrun;<br> <br> %_overrun(_bs=1,_es=1);<br> <br> Now, this probably seems silly. &nbsp;However, <br> 1) I seldom have to comment out large code blocks.<br> 2) The code is executed in sensible segments<br> 3) Analyses are never broken into 2 or 3 files, rather it is broken into 2 or 3 code segments, which are executed or ignored as needed.<br> <br> I just use the macro code blocks to cut the code up into coherent and self-contained segments, and execute the ones which are needed. &nbsp;For that reason, I am almost always working with large blocks of code which I am ignoring. &nbsp; <blockquote type="cite" cite="mid:200110011809.LAA22751@mail9.bigmailbox.com"> <pre wrap=""><br>%macro xyz(&lt;list of inputs&gt;);<br>%if &lt;check on inputs indicates problem&gt; %then %do;<br> %put Failed to specify ...;<br> %goto endmac;<br>%end;<br><br>&lt;major code block goes here&gt;<br><br>%:endmac;<br>%mend xyz;<br><br><br>Defensible? I certainly think so. How would you handle this?<br><br>Dale<br><br><br></pre> <blockquote type="cite"> <pre wrap="">Date: Fri, 28 Sep 2001 15:36:38 -0500<br>Reply-To: Paul Thompson <a class="moz-txt-link-rfc2396E" href="mailto:paul@WUBIOS.WUSTL.EDU">&lt;paul@WUBIOS.WUSTL.EDU&gt;</a><br>Paul Thompson <a class="moz-txt-link-rfc2396E" href="mailto:paul@WUBIOS.WUSTL.EDU">&lt;paul@WUBIOS.WUSTL.EDU&gt;</a> Re: VALUE <a class="moz-txt-link-abbreviated" href="mailto:SAS-L@LISTSERV.UGA.EDU">SAS-L@LISTSERV.UGA.EDU</a><br>I cannot ever see any reason to use GOTO. Please, can a defender<br>provide an example of when a GOTO does something that cannot be done<br>using some sensible DO construct?<br></pre> </blockquote> <pre wrap=""><!----><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>


Back to: Top of message | Previous page | Main SAS-L page