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 (December 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Dec 2006 05:53:44 -0800
Reply-To:     abose <hirak99@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         abose <hirak99@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Optional parameters in a macro
Comments: To: sas-l@uga.edu
In-Reply-To:  <200612201252.kBKBkUWW029135@malibu.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"

Thanks all @Gerhard Hellriegel: That was really cool, exactly what I was looking for!

What I actually need is a macro ILIST which will take max three variables, and return a list like: ILIST(5) --> 1 2 3 4 5 ILIST(3,5) --> 3 4 5 ILIST(1,5,2) --> 1 3 5 (third variable is step)

Now I feel I can do it :) Thanks a lot for helping!

On Dec 20, 5:52 pm, gerhard.hellrie...@T-ONLINE.DE (Gerhard Hellriegel) wrote: > Perhaps like that: > > %macro sum(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13); > %let sum=0; > %do i=1 %to 13; > %if &&a&i= %then %let a&i=0; > %let sum=%eval(&sum+&&a&i); > %end; > &sum; > %mend; > > %put %sum(1,2,3); > > On Wed, 20 Dec 2006 04:21:37 -0800, RolandRB <rolandbe...@HOTMAIL.COM> wrote: > >abose wrote: > >> Hi, > >> Is there any way I can write a macro which will take optional > >> parameters? For example, can I create something like a sum macro which > >> works on 2 OR 3 variables: > > >> %sum(3,4) returns 7 > >> %sum(3,4,5) returns 12? > > >Yes, use enough positional parameters to cover any usage of the macro.


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