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 (March 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 29 Mar 2007 23:49:14 +0000
Reply-To:     toby dunn <tobydunn@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         toby dunn <tobydunn@HOTMAIL.COM>
Subject:      Re: iterative %do loop in macro language
Comments: To: rajasekhargo@YAHOO.COM
In-Reply-To:  <200703292245.l2TJeS5k015432@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed

I have to wonder why you need to do this but since I dont know the bigger picture as David always puts it:

%Macro Iter( List = ) ; %Local I Stop ;

%Let Stop = %Eval( %SysFunc( CountC( &List , %Str( ) ) ) + ( %Length( &List ) > 0 ) ) ;

%Do I = 1 %To &Stop ; %Put Item = %Scan( &List , &I , %Str( ) ) ; %End ;

%Mend Iter ;

%Iter( List = import export configure )

Toby Dunn

To sensible men, every day is a day of reckoning. ~John W. Gardner

The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois

Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter

From: Raj <rajasekhargo@YAHOO.COM> Reply-To: Raj <rajasekhargo@YAHOO.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: iterative %do loop in macro language Date: Thu, 29 Mar 2007 18:45:20 -0400

Hello everyone,

A quick question:

Is there a way in macros iterative do-loop to loop through a series of words? For example, I have a list of words like 'import', 'export', 'configure'.

I need to loop through each of the words like this.

%do i = import, export, configure;

...more macro statements using the value of &i ;

%end;

But macro iterative do loop only allows integer values. I know that we can do this in regular do-loop (like do i= import, export, configure; ). Can we do the same in macros as well?

Thanks in advance for your responses.

Raj

_________________________________________________________________ Mortgage refinance is hot 1) Rates near 30-yr lows 2) Good credit get intro-rate 4.625%* https://www2.nextag.com/goto.jsp?product=100000035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h2a5f&s=4056&p=5117&disc=y&vers=743


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