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 (October 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 18 Oct 2007 15:12:56 +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: My position on default value in Positional & Keyword list for
              Macro program
Comments: To: Hari <>
In-Reply-To:  <>
Content-Type: text/plain; charset="iso-8859-1"

C and D are technically incorrect...

C is wrong because positional parameters have no default value unless you specifically create one in the Macro code.

When you call a Positional Parameter macro you must have all the commas in the call otherwise it will choke and throw an error:

%Macro Junk( , AAA , BBB )

In the above call the first parameter has no value , but since I had to place the comma between it and the second parameter I explicitly gave it a null value.

D is wrong because by simply omiting the keyword parameter you are stating that you will live with what ever value the parameter was defined with.

%Macro Junk( XXX = AAA ) ; %Put &XXX ; %Mend Junk ;

%Junk %Junk() %Junk(XXX = ABC )

Toby Dunn

Compromise is like telling a lie, it gets easier and easier. Each compromise you make, that becomes your standard.

Perfection doesnt exist, once you reach it, its not perfect anymore. It means something else.

> Date: Thu, 18 Oct 2007 07:57:25 -0700 > From: excel_hari@YAHOO.COM > Subject: My position on default value in Positional & Keyword list for Macro program > To: SAS-L@LISTSERV.UGA.EDU > > Hi, > > Im working through a quiz question in online learning. > > If you use a mixed parameter list in your macro program definition, > which of the following is false? > a. You must list positional parameters before any keyword > parameters. > b. Values for both positional and keyword parameters are stored in a > local symbol table. > c. Default values for keyword parameters are the values that are > assigned in the macro definition, whereas positional parameters have a > default value of null. > d. You can assign a null value to a keyword parameter in a call to the > macro by omitting the parameter from the call. > > I chose the answer as "c" while the learning mentions it as "d"? > > I know that "d" is possible because if one runs the following program > > %macro keywordchk(p=); > %put the value of p is &p; > %mend keywordchk; > > %keywordchk() > > Then, the value of the macro variable by default is null (because in > macro definition we didnt assign any value and neither during macro > call). Since d) is possible, so d is not false. > > On other hand, I have issues in wording of c with regards to "whereas > positional parameters have a default value of null" because my > position is that positional parameters dont have any default values to > start with and the user who calls the macro provides null values (and > hence it cannot be termed as default). So, c is not possible and hence > wrong. > > The explanation given in online learning is "In a mixed parameter > list, positional parameters must be listed before any keyword > parameters. Both positional and keyword parameters create macro > variables in the local symbol table. To assign a null value to a > keyword parameter, you list the parameter without a value in the macro > call." > > Please clarify my understanding here. > > hp

_________________________________________________________________ Peek-a-boo FREE Tricks & Treats for You!

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