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 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 5 Nov 2009 15:12:16 +0000
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Murphy Choy <goladin@GMAIL.COM>
Subject:      Re: how to establish variable with macro
Comments: To: Tom Abernathy <>
Content-Type: text/plain

Hi Nicky,

This macro is more efficient than the one you have written. Please use this one instead.

------Original Message------ From: Tom Abernathy Sender: SAS(r) Discussion To: SAS-L@LISTSERV.UGA.EDU ReplyTo: Tom Abernathy Subject: Re: how to establish variable with macro Sent: Nov 5, 2009 9:37 PM

Don't use macro logic do what you can do with DATA step logic. Also use meaningful variable names. I renamed X and Y macro variables based on how they appear to be used. This makes it more obvious that half of your Xnn variables will never be assigned values because of the BY clause on the inner DO loop.

%macro a(nobs,nvars); data b; array x x1-x&nvars; do i=1 to &nobs; do j=1 to &nvars by 2; x(j)=rannor(254115); end; output; end; run; %mend a; %a(10,10);

On Nov 5, 3:08 am, nickyli <> wrote: > > because of my poor english,someone maybe misunderstood the > meaning.however,i have solve the is the procedure: > %macro a(x,y); > data b; > %do i=1 %to &x; > %do j=1 %to &y %by 2; > x&j=rannor(254115); > %end; > output; > %end; > run; > %mend a; > %a(10,10); > we can get different data set by changing macroparameter (x,y)- Hide quoted text - > > - Show quoted text -

Sent from my BlackBerry Wireless Handheld

-- Regards, Murphy Choy

Certified Advanced Programmer for SAS V9 Certified Basic Programmer for SAS V9

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