f



Re: &&&&&& #9

"I have found that while in certain situations this may
be the only way to accomplish something easily, it is over used and causes
way more headaches than it is worth"

My feeling on macros...

Thanks,
Alan

Savian
"Bridging SAS and Microsoft Technologies"

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby
dunn
Sent: Thursday, June 09, 2005 12:56 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: &&&&&&

Alan,

I seem to have started a hail storm here and I probably should have stated
earlier that I don't disagree with SCL or a rework of the code, but rather
building and then sending the code out to a temp file and then %including it
back in I like not.  I have found that while in certain situations this may
be the only way to accomplish something easily, it is over used and causes
way more headaches than it is worth.  As for the rest of your post I am
right behind you.



Toby Dunn




From: Alan Churchill <SASL001@SAVIAN.NET>
Reply-To: Alan Churchill <SASL001@SAVIAN.NET>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: &&&&&&
Date: Thu, 9 Jun 2005 12:47:23 -0600
MIME-Version: 1.0
Received: from malibu.cc.uga.edu ([128.192.1.103]) by mc7-f17.hotmail.com
with Microsoft SMTPSVC(6.0.3790.211); Thu, 9 Jun 2005 11:47:32 -0700
Received: from listserv.cc.uga.edu (128.192.1.75) by malibu.cc.uga.edu
(LSMTP for Windows NT v1.1b) with SMTP id <1.00FB2139@malibu.cc.uga.edu>;
Thu, 9 Jun 2005 14:47:30 -0400
Received: from LISTSERV.UGA.EDU by LISTSERV.UGA.EDU (LISTSERV-TCP/IP release
          1.8d) with spool id 2863721 for SAS-L@LISTSERV.UGA.EDU; Thu, 9 Jun
          2005 14:47:30 -0400
Received: from IPOfCard1.guest-tek.com ([66.193.160.162]) by
listserv.cc.uga.edu (8.12.11/8.12.11) with ESMTP id j59IlULF006633
for <SAS-L@LISTSERV.UGA.EDU>; Thu, 9 Jun 2005 14:47:30 -0400
Received: from alantoshiba (localhost.localdomain [127.0.0.1]) by
IPOfCard1.guest-tek.com (8.11.6/8.11.6) with ESMTP id j59IlPW15741;
Thu, 9 Jun 2005 14:47:26 -0400
X-Message-Info: GQXpnklFM/cj8fTc4hShjcoyWfgNztxbHkaK/EmEO0s=
X-Mailer: Microsoft Office Outlook, Build 11.0.6353
Thread-Index: AcVtINbLm7wFt+qXR3iNjj/4yW/49wAAJ+9Q
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Comments: To: toby dunn <tobydunn@HOTMAIL.COM>
Return-Path: owner-sas-l@LISTSERV.UGA.EDU
X-OriginalArrivalTime: 09 Jun 2005 18:47:32.0366 (UTC)
FILETIME=[B1C492E0:01C56D23]

Toby,

Fair to disagree but the approach I suggested works extremely well, is easy
to debug, and has proven itself time after time. As the famous macro or not
debate showed a few months back, there are lots of ways to handle code
gen...macro is merely 1 way.

The limit here is one of comfort: where does an individual programmer feel
comfortable technology and approach-wise. If macro is it, then that is what
you will tend to drift toward. If it is SCL, as Joe states, then it will be
SCL. Personally, I use macros (to a point), %includes, c#, CodeSmith, and a
host of other methods to gen code depending upon the need.

Here's another way:

List<string> sasCode=new List<string>() ;

GenSasCode("data one;") ;
GenSasCode("   flower=\"Daisy\";") ;
.....

public void GenSasCode(string str)
{
         sasCode.Add(str) ;
}



Now why would I want to do something like the above? Well, it depends on the
situation. If I was building a GUI app based on Windows or else I was trying
to gen code from Excel or Word, the above may be very applicable.

6 ampersands indicates, to me, a major problem and probably means a code and
architectural rework. A primary problem with macros is their abuse and
stretching them beyond what they were intended to handle.


Thanks,
Alan

Savian
"Bridging SAS and Microsoft Technologies"

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby
dunn
Sent: Thursday, June 09, 2005 12:27 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: &&&&&&

Alan,

I disagree with that statement.  I think the best solution would be to build
the dang thing the way he want with less macros.  By sending your code out
then back in is in MO to much hassel for too little.

the whole thingy could be done like this:

data one ;
flower = 'Daisy' ;
color  = 'Yellow' ;
run ;

data two ;
set one ;
call symput ( compress('text'||_n_),compbl(flower||'='||color) ) ;
call symput ( 'index' , compress(_n_) ) ;
run ;

%put &&text&index ;





Toby Dunn




From: Alan Churchill <SASL001@SAVIAN.NET>
Reply-To: Alan Churchill <SASL001@SAVIAN.NET>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: &&&&&&
Date: Thu, 9 Jun 2005 12:20:06 -0600
MIME-Version: 1.0
Received: from malibu.cc.uga.edu ([128.192.1.103]) by mc5-f10.hotmail.com
with Microsoft SMTPSVC(6.0.3790.211); Thu, 9 Jun 2005 11:20:12 -0700
Received: from listserv.cc.uga.edu (128.192.1.75) by malibu.cc.uga.edu
(LSMTP for Windows NT v1.1b) with SMTP id <1.00FB1FC3@malibu.cc.uga.edu>;
Thu, 9 Jun 2005 14:20:10 -0400
Received: from LISTSERV.UGA.EDU by LISTSERV.UGA.EDU (LISTSERV-TCP/IP release
           1.8d) with spool id 2860742 for SAS-L@LISTSERV.UGA.EDU; Thu, 9
Jun
           2005 14:20:10 -0400
Received: from IPOfCard1.guest-tek.com ([66.193.160.162]) by
listserv.cc.uga.edu (8.12.11/8.12.11) with ESMTP id j59IK93S001763
for <SAS-L@LISTSERV.UGA.EDU>; Thu, 9 Jun 2005 14:20:10 -0400
Received: from alantoshiba (localhost.localdomain [127.0.0.1]) by
IPOfCard1.guest-tek.com (8.11.6/8.11.6) with ESMTP id j59IK7W10621;
Thu, 9 Jun 2005 14:20:07 -0400
X-Message-Info: GQXpnklFM/eJUpGQZYbtwDAabDb5cU8er7WLqhcT3GY=
X-Mailer: Microsoft Office Outlook, Build 11.0.6353
Thread-Index: AcVtGhbbLFhlhlw4Ro+yj1aaUUwWagABUY9A
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Comments: To: Talbot Michael Katz <topkatz@MSN.COM>
Return-Path: owner-sas-l@LISTSERV.UGA.EDU
X-OriginalArrivalTime: 09 Jun 2005 18:20:12.0209 (UTC)
FILETIME=[E0287A10:01C56D1F]

This is a prime example I use when I discuss what is wrong with the macro
language. Yes, you can figure it out but an alternative would be to simply
write your data step code out and then bring it back in so you know what is
being submitted.

data _null_ ;
     file 'c:\myfile.sas' ;
     put 'data ...;' ;
     ...more put statements...
run;

%include 'c:\myfile.sas' ;

Others will argue for SCL or something else. Regardless, this application
probably requires a complete rethink if you are using 6 ampersands.

Thanks,
Alan

Savian
"Bridging SAS and Microsoft Technologies"

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Talbot
Michael Katz
Sent: Thursday, June 09, 2005 11:39 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: &&&&&&

Hi.

It requires SIX ampersands to resolve the macro variable example below:

data _null_ ;
   set DS1 end = last ;
   call symput("mlv" || compress(put(_N_,best32.)), mli)
   ;
   call symput(mli, tdt) ;
   if last then do ;
    call symput("mlin", compress(put(_N_,best32.))) ;
   end ;
run ;
%put &&mlv&mlin.  = &&&&&&mlv&mlin. ;

(So, if there are five observations in the data set, and the fifth value of
mli is "DAISY" and the fifth value of tdt is "YELLOW" this will print
out "DAISY = YELLOW")

Why does it take so many ampersands to resolve?  Can someone please explain
this resolution to me so that it gets through my extremely dense skull?

Thanks!


--  TMK  --
"The Macro Klutz"
0
SASL001 (990)
6/9/2005 7:26:10 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
1104 Views

Similar Articles

[PageSpeed] 22

Reply: