[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: macro invocation
From:       Andy Kowalczyk <akowalczyk () WCRINET ! ORG>
Date:       2001-05-31 17:08:09
[Download RAW message or body]

I also got something like this to work (tested yesterday - retyped today:)

%let split=split;
%let yr=98;

%&split&yr;



On Wed, 30 May 2001 15:54:27 -0400, Patrick Smith <PSmith@USSC.GOV> wrote:

>Thanks Jonathan and Nancy for your responses. I  tried %split&yr (and some
attempts at quoting) in v8.1 (Win2000) and it did not work. It's good to
know that it can be done in v8.2.
>
>>>> "Brucken, Nancy" <Nancy.Brucken@PFIZER.COM> 05/30/01 03:32PM >>>
>%split&yr; works fine in v6.12, and again in v8.2.  In v8.0, you have to
use
>%unquote(%nrstr(%split)&yr); to get things to resolve properly.
>   Hope this helps,
>       Nancy
>
>Nancy Brucken
>Clinical/Regulatory Informatics
>Pfizer Global Research & Development, Ann Arbor
>(734) 622-5767
>E-mail address:  Nancy.Brucken@pfizer.com
>
>
>-----Original Message-----
>From: Jonathan Goldberg [mailto:jonathan@MATLOCK.WUSTL.EDU]
>Sent: Wednesday, May 30, 2001 3:28 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: macro invocation
>
>
>Patrick Smith <PSmith@USSC.GOV> asks:
>
>>Hello All,
>>
>>I have macros split98, split99 and split00 and a macro variable yr with
>>value 98, 99 or 00.  Can I use
>>yr to invoke the macro whose last two characters is the value of yr?  For
>>example, if &yr=99, I want to
>>call split99.
>>
>>I suppose that I can use %if %then constructs, but that requires another
>>macro.  I am looking for a
>>one-liner.
>>
>>Thanks for any help.
>
>
>This is surprisingly tricky.  The closest I have come is:
>
>1          %macro xx1;
>2            %put first macro;
>3          %mend xx1;
>4          %macro xx2;
>5            %put second macro;
>6          %mend xx2;
>7          %let x = 1;
>8
>9          %bquote(%xx&x)
>WARNING: Apparent invocation of macro XX not resolved.
>first macro
>10
>11         %let x = 2;
>12
>13         %bquote(%XX&x)
>WARNING: Apparent invocation of macro XX not resolved.
>second macro
>
>which works, but has those annoying warnings.  Anyone do better?
>
>Jonathan Goldberg
>Missouri Alcoholism Research Center
>Dept. of Psychiatry
>Washington University School of Medicine
>40 N. Kingshighway, Suite One
>St. Louis, MO 63108
>314-286-2212

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic