Date: Tue, 29 Dec 2009 07:30:01 -0800
Reply-To: Frank DiIorio <frankdiiorio@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Frank DiIorio <frankdiiorio@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Regarding SAS Macro
Content-Type: text/plain; charset=ISO-8859-1
On Dec 28, 11:06 pm, GNV Resident <sfe...@gmail.com> wrote:
> Hello.
>
> Now I am studying for SAS Advanced Programming in SAS 9.
>
> ================================
> 3 Which of the following correctly references the macro named Printdsn
> as shown
> here:
> %macro printdsn(dsn,vars);
> %if &vars= %then %do;
> proc print data=&dsn;
> title "Full Listing of %upcase(&dsn) data set";
> run;
> %end;
> %else %do;
> proc print data=&dsn;
> var &vars;
> title "Listing of %upcase(&dsn) data set";
> run;
> %end;
> %mend;
>
> a %printdsn(sasuser.courses, course_title days);
> b %printdsn(dsn=sasuser.courses, vars=course_title days)
> c %printdsn(sasuser.courses, course_title days)
> d %printdsn(sasuser.courses, course_title, days)
> ================================
>
> Please take a look at the above problem. In reality, I tried to both
> cases (b) and (c) and obtained that
> they have the same result. I think that means both choices could be
> right answers. But, the answer
> sheet shows that (c) only is the answer. I can't understand why it
> should be.
>
> Can someone explain why the answer is (c)?
>
> Thank you so much.
[c] is correct because the %macro statement defines two positional
(not keyword, as used in [b]) parameters. Notice that [a] is
identical to [c] save for the semicolon. One could argue that the
semicolon, though unnecessary, does not make the macro call wrong, but
then that would incite one to start railing about how goofy it is to
measure someone's competence in a process (programming, debugging,
design, etc.) by a multiple choice test.
|