Date: Fri, 12 Apr 1996 04:02:19 GMT
Reply-To: Netnews Server <NETNEWS@AMERICAN.EDU>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Netnews Server <NETNEWS@AMERICAN.EDU>
Organization: Brigham Young University, Provo UT USA
Subject: Re: passing var to macro
Evan Cooch <cooch@fraser.sfu.ca> wrote:
>I suppose I should know the answer to this, but if I ever did, I've
>forgotten.
>
>I want to pass a value from a particular PROC to a macro for further
>analysis. For example, suppose I use PROC MEANS to output a sample mean.
>I then want to pass this mean to a macro which uses a Monte Carlo
>approach to estimate it's significance.
>
>The basic logic might look like:
>
>proc means;
> var x;
>output out=means mean=mean_x;
>
>%macro monte;
>%do iter=1 %to 1000;
>
><randomly permute the data>
>proc means data=random noprint;
> var x;
>output out=randmean mean=test_m;
>
>data randmean;
> set randmean; if test_m>&mean_x then do; <- here is the problem part;
> flag=1; end;
> else flag=0;
>
><write the result out to a file>
>
>%end;
>%mend;
>
>So, in the "test" paert, I want to compare the value of the mean
>calculated in the macro with the "original" value calculated prior to the
>macro. How can I pass the "original" mean to the macro?
>
>
>Any help appreciated. Thanks!
>
----------------------------------------------------------------
Since you already have your proc means results out to a dataset,
you can do a data step on that dataset (MEANS) and use a
call symput. This puts the value of mean_x into a macrovar.
For example, right after your proc means,
data _null_;
set means;
call symput('mean_x',mean_x);
run;
Later in your code, you could then access the macrovariable,
using &mean_x.
Hope this helps.
Kyle McBride
Department of Statistics
Brigham Young University
Provo, Utah
mcbride@byu.edu
|