Date: Wed, 15 Jun 2005 15:41:57 -0400
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Harry Droogendyk <harry.droogendyk@RBC.COM>
Subject: Re: When to use Macro (was Things to ponder when you program)
Content-Type: text/plain; charset="iso-8859-1"
I'm now in the habit of ensuring every macro I write for wider publication ( ie. available in server SASAUTOS location ) accepts a positional parm called &help. Invoking the macro with a single positional parm of ? or HELP produces the macro "documentation", reason for existence, parms and their description and sample usage.
eg. produces LOG contents of:
data=%str(date to be written to signal file ));
Depending on value of &action, macro writes, deletes or checks a signal file
Parms: &dir - signal file directory
&process - process name, macro adds .batch_flag to &process to create signal file name
&action - D = delete signal file
W = write signal file, will delete existing signal file before writing
C = check signal file, returns 0 ( zero ) if file not found,
returns contents of file if found, i.e. value of &data
when file was created, or 1 if file is empty
&data - specification of signal file contents, e.g. time of completion,
record counts etc.. - optional
- if &data is null or omitted, an empty signal file will be created
Return code of 0 is successful execution for write/delete actions
Use: %let rc = %batch_flag(dir=h:\users\853924157\data,
data=%str(Successful end - %sysfunc(datetime(),datetime20.));
[mailto:firstname.lastname@example.org]On Behalf Of Dianne Rhodes
Sent: Wednesday, June 15, 2005 2:05 PM
To: toby dunn; cassell.david@EPAMAIL.EPA.GOV; SAS-L@LISTSERV.UGA.EDU
Subject: RE: When to use Macro (was Things to ponder when you program)
Toby Dunn wrote :
> Ian hasn't even written about this. He has brought the
> question up in some of his earlier papers but I have yet to
> see an answer. In short while I don't have a answer or even
> know if one exists or is possible, I think we should at least
> attempt a answer. It may not be great at first but with time
> like a lot of things it should get better with time and refinement.
I don't think that's at all true, Ian has written a lot about this.
He may not have put forward rules, per se, but certainly he has said
that you shouldn't use macro until you are a proficient programmer, and
that macro should be used when you find repetition in your code, i.e.
"wall paper" code. In order to see the pattern, you usually have to
write the code first! At least I do. Even when I know I want to make a
macro, a write SAS open code first, test it, make sure it works. Too
often us more senior folks are accused of using macro to ensure job
security by less experienced folks who have no idea how to find errors
in "macrotized" code. Its unfair to them to pass on the code to them
unless its been well tested and documented. I usually put in "usage
notes." Like these:
/* Usage Notes */
/* Set Y1 to Start Year Y2 to End year in Macro Parems list */
/* Produces Overall History Report */
/* To See Standard Error terms Set USESE to YES */
And I use key word parems and try to put in useful defaults for them
And a point on list etiquette, can folks please sign their messages?
I'm seeing lots of new messages with names like "SAS-L subscriber" and
no signature. If you want to be named Rookie of the year, we have to
know who you are.
And Toby, get a spell checker!
I will have more comments on the original post later.
Dianne Louise Rhodes
Sr. Systems Analyst
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations.
Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.
If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent.
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.