Date: Tue, 30 Mar 2004 15:53:27 -0500
Reply-To: Ed Heaton <EdHeaton@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ed Heaton <EdHeaton@WESTAT.COM>
Subject: Re: Comments in Macros
Content-Type: text/plain
Daniel,
This code would not work in a macro and similar non-macro code will not work
outside a macro. The problem is that the %ELSE statement must immediately
follow the end of the %THEN block. You have a statement between the two,
namely the comment statement. You can change it to a comment with /* and */
and it will work.
Ed
Edward Heaton, SAS Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1600 Research Boulevard, RW-3541, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 610-5128
mailto:EdHeaton@Westat.com http://www.Westat.com
-----Original Message-----
From: Daniel Normolle [mailto:monk@UMICH.EDU]
Sent: Tuesday, March 30, 2004 3:25 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Comments in Macros
Hello,
Is there any reason the following code should not run?
SAS (V8.2 on Red Hat 9) complains to me that the first
%if-%then block is not closed. Take the comment out,
comment the comment out with /* ... */ or change * to %*
in the comment and it works. I'm happy to do that, but
I'd like to understand the error of my ways...Thanks! dpn
%macro badcom;
%let x=1;
%if &x=1 %then %do;
%put This should print;
%end;
*------This comment is the problem;
%else %do;
%put This should not;
%end;
%mend badcom;
%badcom
|