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 (March 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 9 Mar 1998 10:37:14 -0800
Reply-To:   "kmself@ix.netcom.com" <kmself@ix.netcom.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
Comments:   To: Wayne Wilson <w3595@SIERRA.NET>, "\"'TimPi<timpi@fmrco.com>'\" <TimPi" <timpi@fmrco.com>
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 variable */

macro: %sysfunc(index(foo, bar)); ...is trying to match the string 'bar' with the string 'foo' and returns 0.

%sysfunc(index( &foo, &bar )); ...expands and compares macrovariables &FOO and &BAR.

data step: index(foo, bar); ...is trying to match the contents of the variable FOO with the contents of the varaible BAR, with results depending on their values.

index("foo", "bar") ...attempts to match strings, returning 0.

On Sunday, March 08, 1998 4:46 PM, Wayne Wilson [SMTP:w3595@SIERRA.NET] wrote: > Tim, > When I removed the " before the &ctry macro variable, the function > worked > as expected. The value of CTRY was being interpreted as "uks instead of > uks. > > %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 <timpi@fmrco.com> > > 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 > following > > 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 (kmself@ix.netcom.com)

What part of "gestalt" don't you understand? (Welchen Teil von "Gestalt" verstehen Sie nicht?)


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