LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 4 Sep 2007 21:08:25 +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: my macro needs a time machine
Comments: To: gzuckier@SNAIL-MAIL.NET
In-Reply-To:  <1188939103.214887.23510@k79g2000hse.googlegroups.com>
Content-Type: text/plain; format=flowed

What you need is to redesign your macro code, basically you havent abstracted far enough back to allow the macro to do the job you need. I see this as a one off program or project specific macro.

Untested........

%Macro MyJoin( File1 = , File2 = , StartAge = , OutFile = ) ;

Proc SQL ; Create Table &OutFile As Select A.* , B.Occurrences From Stuff As A , ( Select Count( * ) As Occurrences From ID_List Where Age >= &StartAge Group By ID ) As B Where A.ID = B.ID ;

%Mend MyJoin ;

Now you should have one macro that does the equvalent of both of your macros and shouldnt have the Macro timing problem.

Toby Dunn

Comprimise is like telling a lie, it gets easier and easier. Each comprimise you make, that becomes your standard.

Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else.

From: z <gzuckier@SNAIL-MAIL.NET> Reply-To: z <gzuckier@SNAIL-MAIL.NET> To: SAS-L@LISTSERV.UGA.EDU Subject: my macro needs a time machine Date: Tue, 4 Sep 2007 13:51:43 -0700

I have a big chunk of boilerplate code defined as a macro variable, for consistency and ease of maintenance, that gets used in several steps. For instance, (simplified for clarity),

%let boilerplate = (select id, count(*) as occurrences from id_list where age >= &startage. group by id) ;

And, when it gets used,

%macro firststuff(startage=,outfile=); proc sql; create table &outfile. as select a.*, b.occurrences from stuff a, &boilerplate. b where a.id = b.id; %mend;

%macro secondstuff(startage=,outfile=); proc sql; create table &outfile. as select a.*, b.occurrences from otherstuff a, &boilerplate. b where a.id = b.id; %mend;

etc.

so that I can run %firststuff(startage=18,outfile=stuff18); %secondstuff(startage=18,outfile=otherstuff18); %firststuff(startage=90,outfile=stuff90); %secondstuff(startage=90,outfile=otherstuff90);

etc.

Of course, what happens is that the %let gives me a warning WARNING: Apparent symbolic reference STARTAGE not resolved. since startage isn't defined yet, until the macro gets called later down; but it works OK.

It runs OK, but it would be nice to get rid of that return code = 1. Any ideas? TIA.

_________________________________________________________________ Discover sweet stuff waiting for you at the Messenger Cafe. Claim your treat today! http://www.cafemessenger.com/info/info_sweetstuff.html?ocid=TXT_TAGHM_SeptHMtagline2


Back to: Top of message | Previous page | Main SAS-L page