|Date: ||Mon, 9 Mar 1998 10:37:14 -0800|
|Reply-To: ||"firstname.lastname@example.org" <email@example.com>|
|Sender: ||"SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>|
|From: ||"Karsten M. Self" <kmself@IX.NETCOM.COM>|
|Organization: ||Self Analysis|
|Subject: ||Re: Macro Question|
|Content-Type: ||text/plain; charset="us-ascii"|
FWIW, the quotes in the string '"jpy uks"' are also redundant, as Macro
treats all string literals as string constants. Quotes are required in
DATA step to distinguish string literals from variable names. In macro, a
macrovariable is designated with the prefix '&'.
Illustration: you don't quote assignments in a %LET statement:
%let foo= quixly quux; /* typical */
Not: %let foo= "quixly quux"; /* You can do it, but '"'s become part of
...is trying to match the string 'bar' with the string 'foo' and
%sysfunc(index( &foo, &bar ));
...expands and compares macrovariables &FOO and &BAR.
...is trying to match the contents of the variable FOO with the
contents of the varaible BAR, with results depending on their values.
...attempts to match strings, returning 0.
On Sunday, March 08, 1998 4:46 PM, Wayne Wilson [SMTP:w3595@SIERRA.NET]
> When I removed the " before the &ctry macro variable, the function
> as expected. The value of CTRY was being interpreted as "uks instead of
> %if %sysfunc(index("jpy uks",&ctry)) > 0 %then %do;
> /* Removed quotation mark before &ctry macro variable */
> Hope this helps.
> Wayne Wilson
> Carson City, NV
> > From: Tim Pi <firstname.lastname@example.org>
> > To: SAS-L@UGA.CC.UGA.EDU
> > Subject: macro qestion
> > Date: Sunday, March 08, 1998 11:04 AM
> > Hi SAS users,
> > I thought I know sas/macro very well before I encounted the
> > problem. could anyone please help? Thanks!
> > ******
> > %let ctry = uks;
> > run;
> > %if %sysfunc(index("jpy uks","&ctry)) > 0 %then %do;
> > .....
> > %end;
> > *****
> > Why the %if condition is always false?
> > SAS log shows that macro variable ctry is resovled as uks
> > but the result of %if condition is false.
> > Thx!
> > Tim Pi
Karsten M. Self (email@example.com)
What part of "gestalt" don't you understand?
(Welchen Teil von "Gestalt" verstehen Sie nicht?)