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 (April 2000, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 Apr 2000 15:33:30 -0400
Reply-To:     "Brucken, Nancy" <Nancy.Brucken@WL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Brucken, Nancy" <Nancy.Brucken@WL.COM>
Subject:      Re: Macro and comment lines question
Comments: To: "WHITLOI1@westat.com" <WHITLOI1@westat.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi Ian, Thank you very much! I just must not have tried putting a SAS comment between %END and %ELSE before (must have either been lucky, or forgotten about the error messages generated). Thank you also to the others who responded to my question (Ron Fehd, Pete Lund, Michael Bramley, Walter Smetsers and Ed Confer). Nancy

-----Original Message----- From: WHITLOI1@westat.com [mailto:WHITLOI1@westat.com] Sent: Thursday, April 20, 2000 12:41 PM To: Brucken; Nancy Subject: Re:Macro and comment lines question

Nancy,

* anything ; is a SAS statement not a macro comment. When it is placed between the %END and %ELSE the chain is broke and the %ELSE is not expected. If you like the non-working form then use %* anything ; This is a macro comment and the macro compiler can handle it as a comment, so it doesn't end the chain.

Ian Whitlock <whitloi1@westat.com>

____________________Reply Separator____________________ Subject: Macro and comment lines question Author: "Brucken; Nancy" <Nancy.Brucken@WL.COM> Date: 4/20/2000 10:49 AM

Hi all, Does anyone have any idea why the following piece of macro code works:

%if &iarxlab ne %str() %then %do; <lots of stuff> %end;

%else %do;

*========================================================================*; * If treatment group labels have not been specified, then use dummy *; * labels. *;

*========================================================================*; data demo (drop=rxgrp); set demo; length cmed $ 30; cmed = 'Drug ' || trim(left(rxgrp)); MED=index('ABCDEFGHIJKLMNOPQRSTUVWXYZ',upcase(trim(left(rxgrp)))); run;

%end;

while the following code produces error messages regarding the existence of a %ELSE without a matching %DO, and a %END without a %DO:

%if &iarxlab ne %str() %then %do; <lots of stuff> %end;

*========================================================================*; * If treatment group labels have not been specified, then use dummy *; * labels. *; *========================================================================*;

%else %do;

data demo (drop=rxgrp); set demo; length cmed $ 30; cmed = 'Drug ' || trim(left(rxgrp)); MED=index('ABCDEFGHIJKLMNOPQRSTUVWXYZ',upcase(trim(left(rxgrp)))); run;

%end;

The only difference between the two pieces of code is the placement of the comment lines relative to the %ELSE. Everything else is identical between the two versions (and in fact, the first version was created by merely cutting and pasting the comment line before the %ELSE- there were no stray characters in the comment lines). Thank you very much, Nancy

Nancy Brucken Parke-Davis, Clinical Informatics (734) 622-5767 E-mail address: Nancy.Brucken@wl.com


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