Date: Sat, 5 Nov 2005 06:23:14 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: using macro to assign a Global Variable by condition
In-Reply-To: <BAY103-F167D54D9AA5535A8A2ECCDB0630@phx.gbl>
Content-Type: text/plain; format=flowed
LOL, David...
I will have you know I didn't have any snuff in when I wrote that post, hmmm
maybe that was the problem.
In any event I had thought about using a format instead of a macro, but
there was just too little information about the use of the macro var firstwk
and the overall design of the program.
The thought occured to me when i first started to write my response and
again when I was at the end but at that point I was getting tired of writing
and needed a dip of snuff and a shiner.
It did finally give me a chance to solidify a thought that has been running
around in my balding head. That being %macros basically can do two things,
either conditionaly submit code to be processed or return a value back
(essentually a user defined function). The method i chose was a user
defined function, hense the examples I gave (hey I had a whole bunch i
almost included).
Now I am off to bed to dream about macro scoping issues and differences when
you use pro sql vs %let vs %macros.
Toby Dunn
From: David L Cassell <davidlcassell@MSN.COM>
Reply-To: David L Cassell <davidlcassell@MSN.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: using macro to assign a Global Variable by condition
Date: Fri, 4 Nov 2005 22:09:54 -0800
tobydunn@HOTMAIL.COM replied:
> [okay, I'm eliding a lot of material here]
>
>When I see any macro that does not have any parameters Big Red Flags start
>raiseing thmselves in my mind and when I also don't see any of the macro
>vars created by the %Macro declared as either local or global, I stop and
>start reevaluating the approach I have taken.
>
>A parameterless macro tells me to start looking at the design. The basic
>question I ussual start with is asking myself can i do this without using a
>%macro wrapper, 99% of the time the answer is yes.
>Think of it this way, all a %macro is going to do is create some code for
>SAS to run. If I am not going to pass it anything to use as a way to say
>run this code or run that code, then i might as well have saved myself the
>trouble of writing and debugging the macro and just wrote the thing in open
>code. O yeah that one percent of the time where i use a %macro with no
>parameters, its simply because I choose to use a macro %do-loop out of
>shear
>lazyness.
>
>I also have found very little use for global macro vars (thanks to Ian).
>Proper code design and a few neat tricks and i have eliminated them from my
>code. Thus there is no chance of some one accidently over writting one of
>them.
>
> [more cuts by me]
>
>Hmmmm lets see here no macro var declaration, no parameters, (not looking
>good so far), if I was a person reading your code here for the first time i
>would start saying hey what is the macro var 'sp' used for, what does
>%props
>do and does it use 'sp' or some other macro var to help run it (ie is there
>some secret contract between %props and SP or any other macro var for that
>matter), and finally hey where in the world did &frstwk come from and how
>did it get its value.
>And o yeah why in the world did the author %include a %macro instead of
>just
>compiling the darn thing, save it in a macro library and then just use the
>dang thingy.
>
> [even more cuts]
Boy, those Texans. They get all bent out of shape about stuff, don't they?
Don't worry, it's probably just a snuff overload. :-) :-)
I believe that Toby is right about your design structure. But I'm going
to suggest that you don't need macros at all.
If the whole point is only to provide FIRSTWK values given particular
character
variable values, then I would define an invalue using PROC FORMAT and drop
all the macro code.
HTH,
David
--
David L. Cassell
mathematical statistician
Design Pathways
3115 NW Norwood Pl.
Corvallis OR 97330
_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/