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 (November 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 9 Nov 2005 07:57:49 -0500
Reply-To:     Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject:      Re: Assign multiple values to multiple Macro Variables
Comments: To: dale Remus <hellangel_987@YAHOO.COM>

Hi Dale,

It depends what you want it to do. The SAS syntax seems correct. But the logic may be different than intended: PROC MEANS creates three variables U1, U2 and U3. You have the data step running for 3 times, while you could do with just one time and a threefold CALL SYMPUT statement in a macro loop. The statement creates the macro variable X for every original U1, U2 and U3. Only the last one is kept. You probably want the values of x to be the macro variable's name. Furthermore your U# values are numeric, which should explicitly be converted to character (instead of implicitly by SAS) before being used in the CALL SYMPUT statement. Very likely you should replace the code by (*untested*):

proc means mean; var x y z; output out=m mean=u1-u3; run;

%Macro a; data _NULL_; set m; * Just one record; %do i=1 %to 3; call symput("m&i",INPUT(u&i,BEST12.6)); * or other format; %end; run; %mend; %a;

or instead of the macro %DO loop the following data step DO loop:

DO I = 1 TO 3; CALL SYMPUT ("M" || LEFT(INPUT(I,1.)), INPUT ("U" || LEFT(INPUT(I,1.)),BEST12.6)); * or other format; END;

or using an array (all *untested*):

ARRAY U U1 -- U3; DO I = 1 TO 3; CALL SYMPUT ("M" || LEFT(INPUT(I,1.)), INPUT (U(I), BEST12.6)); * or other format; END;

Regards - Jim. -- Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign) http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer always teaches me something new I thought I knew already.

[common disclaimer]

On Tue, 8 Nov 2005 22:35:48 -0800, Dale Remus <hellangel_987@YAHOO.COM> wrote:

>The means of three variables need to be stored in >three Macro variables. > >Can you tell me what is wrong with the following macro > > >Thanks > > >proc means mean; >var x y z; >output out=m mean=u1-u3; >run; > >%Macro a; >%do i=1 %to 3; > data _NULL_; > set m; > x="m&i"; > call symput("x",u&i); > run; >%end; >%mend; >%a; > > > >__________________________________ >Yahoo! FareChase: Search multiple travel sites in one click. >http://farechase.yahoo.com


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