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 (February 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 12 Feb 1996 17:54:00 -0500
Reply-To:     Yanhui.Zhang@FNB.SPRINT.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Yanhui Zhang <Yanhui.Zhang@FNB.SPRINT.COM>
Subject:      Re: Macro Confusion

I don't know you got the answer or not.

You actually don't need %str and %bquote because Macro will not misinterpret. Try this:

%macro keepmc(yr=yr); tot&yr (keep=

%do i=1 %to 8; t&i&yr %end; ); %mend keepmc;

You missed one semicolon after the ending parentheses.

______________________________ Reply Separator _________________________________ Subject: Macro Confusion Author: at INTERNET Date: 2/9/96 9:11 AM


I have encountered a macro variable I can't seem to resolve and I don't know why.

I have included the log produced by running two versions of the macro. I changed the tail part of var1 from %str(%( keep=) to %str(%( keep%=). The two versions put out very different results: version 1 generated "TOT94 (keep" while version two generated "TOT94( KEEP%= T194 T294 T394 T494 T594 T694 T794 T894 )". What I want is "TOT94( KEEP= T194 T294 T394 T494 T594 T694 T794 T894 )". Quotes not included in macro resolution.

My final goal is to generate a data statement with several data sets each having a separate keep option. ie data tot1 (keep= t11 t12 t13) tot2 (keep= t21 t22 t23) tot3 (keep=t31 t32 t33) etc. ;

Can anyone explain where my error is?

Thank you, Kelley

Log is included below:

NOTE: Copyright (c) 1989-1995 by SAS Institute Inc., Cary, NC, USA. NOTE: SAS (r) Proprietary Software Release 6.11 TS020 Licensed to INTERMEDICS, INC., Site 0016778003.

1 %macro keepmc(yr=yr); 2 %let var1=tot&yr%str(%( keep=); 3 %let var2=%str(%)); 4 %bquote(&var1) 5 %do i=1 %to 8; 6 t&i&yr 7 %end; 8 %bquote(&var2) 9 %mend keepmc; 10 options mprint nosymbolgen nomlogic; 11 data %keepmc(yr=94);


12 %macro keepmc(yr=yr); 13 %let var1=tot&yr%str(%( keep%=); 14 %let var2=%str(%)); 15 %bquote(&var1) 16 %do i=1 %to 8; 17 t&i&yr 18 %end; 19 %bquote(&var2) 20 %mend keepmc; 21 22 23 data %keepmc(yr=94);

WARNING: The variable T194 in the DROP, KEEP, or RENAME list has never been referenced.


NOTE: The DATA statement used 23.07 seconds.

- 23 MPRINT(KEEPMC): TOT94( KEEP%= T194 T294 T394 T494 T594 T694 T794 T894 ) ERROR 23-7: Invalid value for the KEEP option.

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