Date: Wed, 11 Dec 2002 13:23:22 -0500
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: recruiting cheesy, sleasy SAS tricks
Content-Type: text/plain; charset="iso-8859-1"
Roger,
For this sleaze you should also include things like
if 0
%do i = 1 %to &n ;
or &&v&i
%end ;
then ... ;
where 1
%do i = 1 %to &n ;
and &&v&i
%end ;
;
x = 0
%do i = 1 %to &n ;
+ &&v&i
%end ;
;
They all trade a little bit of execution time for simpler code.
IanWhitlock@westat.com
-----Original Message-----
From: Roger Lustig [mailto:trovato@BELLATLANTIC.NET]
Sent: Wednesday, December 11, 2002 8:50 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: recruiting cheesy, sleasy SAS tricks
Over the years I've written some monster macros that run a whole string
of analyses and produce various outputs. These involve subsetting the
data in more than one way. (Validation samples, data from different
points in time, etc., etc.) To simplify building WHERE statements, I use
WHERE 1=1;
%IF <macro-condition #1> %THEN %DO;
WHERE ALSO <macro-driven filter #1>;
%END;
%IF <macro-condition #2> %THEN %DO;
WHERE ALSO <macro-driven filter #2>;
%END;
...etc...
This way I don't have to worry about the different syntax of the first
WHERE statement.
Cheesy? Sleazy? Lazy is more like it. Yeah!
Roger Lustig
Michael L. Davis wrote:
> Hello Friends,
>
> I'd like to do a Coder's Corner presentation at NESUG next year on the
subject of "Cheesy, Sleasy SAS Tricks". As an example, when coding SCL
programs, I'm in the habit of including the statement:
>
> rc=rc ;
>
> to suppress the compiler warning that I'm creating the variable rc but not
using it.
>
> I'd welcome additional candidates for the role of "cheesy, sleasy tricks".
To qualify, they need to be coding declarations or other constructions that
suppress the literal mindedness of SAS or its sometimes over-solicitous
manner of trying to protect us from ourselves.
>
> I'll be sure to acknowledge useful contributions, selected or otherwise,
in the acknowledgement section of the presentation.
>
> BTW, thanks to all for the help last week with regards to reordering the
PDV. Unfortunately, the friend for whom I was trolling wanted as easy a
method as the RETAIN statement. The ATTRIB statement was to change the
length of a variable brought in by a SET statement. So combining the RETAIN
and ATTRIB statements did not work (the length was not changed by the ATTRIB
statement).
>
> - Michael "Mad Doggy" Davis
>
> Michael L. Davis
> Bassett Consulting Services, Inc.
> North Haven CT 06473-3712
> web: http://www.bassettconsulting.com
> email: michael@bassettconsulting.com
> tel: 203-562-0640