From: Tom Abernathy on
Ankur -
Write the external file as SAS statements and use %INC in the
second program. Use single quotes around the %LET and double quotes
around &modelvars.

In the first program use:

data _null_;
file 'modelvars.sas';
put '%let modelvars=' "&modelvars;" ;
run;

In the second program use:

%inc 'modelvars.sas';


On Jan 7, 9:30 pm, iw1...(a)GMAIL.COM (Ian Whitlock) wrote:
> Ankur,
>
> It is not clear to me whether the validation is done in the same job
> as model building.
> If it is the same job then I would have a simple macro
>
>     %macro varlist ; x y z %mend varlist ;
>
> Otherwise, I might have
>
>     data lib.cntl ;
>        mvar = "varlist" ;
>        value = "x y z" ;
>     run ;
>
> in the model building job and
>
>     data _null_ ;
>        set lib.cntl ;
>        call symput (mvar, value) ;
>     run ;
>
> in both jobs.
>
> More in line with your thought one could have.
>
>     data _null_ ;
>        file cntl ;
>        put '%let varlist = x y z ;' ;
>     run ;
>
> in the model building job and use %INCLUDE in both jobs.
>
> Ian Whitlock
> ==============
>
> On Jan 6, 2010, at 6:49 PM, Ankur Bohra wrote:
>
>
>
> > Hi,
> > Thanks a lot for your responses.
>
> > In my project I am building a logistic model. There I develop the
> > model in one code. I store model variables in a macro variable i.e.
> > %let varlist=v1 v2 v3;
> > proc logistic data=x;
> > model y = &varlist.;
> > and output the model coefficients in a permanent dataset.
>
> > I do out of time validation in a different file. Here I am using
> > proc score ... however i do not want to update the variable list in
> > the out of time validation code.  So i need a mechanism to get macro
> > variable varlist from development code to validation code. So I
> > thought I will create a text file with contents %let varlist=v1 v2
> > v3; from within the development code. Hence the query. I realize
> > there is a better way to do this however I was trying out this make
> > shift arrangement and got stuck!!! Will appreciate if you could help
> > me with a cleaner way to do this.
>
> > Thanks,
> > Ankur Bohra.
>
> > On Thu, Jan 7, 2010 at 3:16 AM, Ian Whitlock <iw1...(a)gmail.com> wrote:
> > Ankur,
>
> > You have gotten answers to your question, but the big
> > question is why you want to do this.  If we knew the
> > problem you wanted to solve that caused you question,
> > someone would probably give you a much better way to
> > solve it.
>
> > Indirection such as
>
> >   %let macvar - modelvars ;
> >   %let &macvar = x y z ;
> >   %put &&&macvar ;
>
> > can be very useful and is an important pattern for
> > exporting local variables to an external environment.
> > However,
>
> >   %let myvar = %nrstr(%let modelvars =) ;
> >   %unquote(&myvar) x y z ;
> >   %put &modelvars ;
>
> > is just very obscure code.  In general, macro can be good
> > for generating SAS code, but it is a very poor language for
> > generating macro code.
>
> > Ian Whitlock
> > ===============
>
> > Date:         Wed, 6 Jan 2010 08:48:44 -0800
> > From:         ankur <ankur.bo...(a)GMAIL.COM>
>
> > Subject:      Issue with %let
>
> > How do I make a macro variable take value "%let modelvars= " ???
> > Following doesn't work
> > %let myvar = %let modelvars= ;
>
> > Thanks,
> > Ankur Bohra.- Hide quoted text -
>
> - Show quoted text -