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 (April 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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>
Comments:     RFC822 error: <W> Incorrect or incomplete address field found and
              ignored.
Comments:     RFC822 error: <W> Incorrect or incomplete address field found and
              ignored.
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


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