Date: Mon, 15 Aug 2011 15:55:33 +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: Setting macro variables in a legacy system
In-Reply-To: <CACT-pRyp1twQe4qpC50VRtSaP_WmaNRU35Neq35A0g8aAuvFOw@mail.gmail.com>
Content-Type: text/plain; charset="Windows-1252"
Well I havent seen a reply so ill chim in. Richard, once it gets this bad anything short of reworking it just a going to have draw backs some where. So if you cant get them to let you redesign it go with the what you came up with.
Toby Dunn
If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain.
“Any idiot can face a crisis—it’s day to day living that wears you out”
~ Anton Chekhov
> Date: Mon, 15 Aug 2011 08:02:27 -0400
> From: rdevenezia@GMAIL.COM
> Subject: Setting macro variables in a legacy system
> To: SAS-L@LISTSERV.UGA.EDU
>
> Consider a legacy system that has several prep files that each need to
> be modified before running.
>
> prep1.sas
> -----
> %let p=; %* set p to ..., must be same in all pgm;
> %let x=; %* set x to ...;
> %let y=; %* set y to ...;
> %let z=; %* set z to ...;
>
> prep2.sas
> -----
> %let p=; %* set p to ..., must be same in all pgm;
> %let a=; %* set a to ...;
> %let b=; %* set b to ...;
> %let c=; %* set c to ...;
>
> start.sas
> -----
> %let p=; %* set p to ..., must be same in all pgm;
> %let r=; %* set r to ...;
> %let s=; %* set s to ...;
> %let t=; %* set t to ...;
> %include codebase(prep1);
> %include codebase(prep2);
> %include codebase(main);
>
> Further suppose a study of perturbation over 20+ input sets is to be
> done. Instead of editing the prep1, prep2 and start files 20+ times
> there should be a way to communicate preset macro variables to the
> legacy system.
>
> pstudy.sas (could be code gen'd from a data source)
> -----
> %let p=p1;
> %let x=x1; %let y=y1; %let z=z1;
> %let a=a1; %let b=b1; %let c=c1;
> %let r=r1; %let b=s1; %let t=t1;
> %include codebase(start);
> ...
> %let p=pN;
> %let x=xN; %let y=yN; %let z=zN;
> %let a=aN; %let b=bN; %let c=cN;
> %let r=rN; %let b=sN; %let t=tN;
> %include codebase(start);
>
> However, the hard-coded blank assignments in the prep files are problematic.
>
> One approach being considered is this:
> - add to top of start
> %macro inherit(mvar);%if %symexist(&mvar) %then &&&mvar;%mend;
> - change prep files to inherit
> %let p=%inherit(p);
> %let <mvar>=%inherit(<mvar>);
>
> What are some potential pitfalls, or is there a better approach ?
>
> Thanks,
> Richard
|