| 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. I try to work with careful indenting.
I would like SAS to implement labeled %END statements, which would greatly
help. <br>
<br>
At least with an %DO-%END, you know where you are going. 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. Sounds like you could do
the same. Get rid of those pesky GOTOs, to boot :-><br>
<br>
My normal coding technique is to write everything inside macros anyway. For
instance, here is my generic code structure:<br>
<br>
%macro _overrun(_bs=1,_es=2);<br>
%if (&_bs <= 1 & 1 <= &_es) %then %do;<br>
6000 lines of code<br>
%end;<br>
%if (&_bs <= 2 & 2 <= &_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. 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. For that reason, I am almost
always working with large blocks of code which I am ignoring.
<blockquote type="cite" cite="mid:200110011809.LAA22751@mail9.bigmailbox.com">
<pre wrap=""><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><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"><paul@WUBIOS.WUSTL.EDU></a><br>Paul Thompson <a class="moz-txt-link-rfc2396E" href="mailto:paul@WUBIOS.WUSTL.EDU"><paul@WUBIOS.WUSTL.EDU></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>
|