| Date: | Thu, 28 Aug 2003 09:06:36 -0400 |
| Reply-To: | Ian Whitlock <WHITLOI1@WESTAT.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Ian Whitlock <WHITLOI1@WESTAT.COM> |
| Subject: | Re: macro processing question |
|
| Content-Type: | text/plain |
|---|
Paul,
But indeed...
Ian
-----Original Message-----
From: Paul Dorfman [mailto:paul_dorfman@HOTMAIL.COM]
Sent: Wednesday, August 27, 2003 4:18 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: macro processing question
Ian,
It has just occurred to me that it may be simpler to avoid ORing (and
associated quoting complexity) altogether by
%macro qin (list= , srch=) ;
%sysfunc(indexw(&list, &srch))
%mend qin ;
%put %qin (list=1 22 333 4444, srch=333) ;
%put %qin (list=1 22 333 4444, srch=444) ;
Kind regards,
=================
Paul M. Dorfman
Jacksonville, FL
=================
>From: Ian Whitlock <WHITLOI1@WESTAT.COM>
>Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: macro processing question
>Date: Wed, 27 Aug 2003 12:20:01 -0400
>
>Ryan,
>
>In version 8 you can not use IN(&x1,&x2,&x3), but in some version of
>version 9 you can. %IN will be a reserved for
>
> %do i %in (&x1,&x2,&x3) ;
>
>If I remember correctly, but I don't know when.
>
>Several macros to generate
>
> &i=5 or &i=7 or &i=8
>
>have been discussed on SAS-L within the last year. Paul Dorfman
>probably introduced one along these lines.
>
>%macro chkin ( var , list ) ;
> %let list = %qsysfunc(compbl(&list)) ;
> %let list = %qsysfunc(tranwrd(&list,%str( ), %nrstr( or &&&var=))) ;
> %unquote(%nrstr(&&&var=)&list)
>%mend chkin ;
>
>/* test code */
>%let lk = 6 ;
>%put %eval(%chkin ( lk , 1 4 7 )) ;
>%let lk = 4 ;
>%put %eval(%chkin ( lk , 1 4 7 )) ;
>
>IanWhitlock@westat.com
>-----Original Message-----
>From: Ryan [mailto:rlee_at_channing@YAHOO.COM]
>Sent: Wednesday, August 27, 2003 11:36 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: macro processing question
>
>
>In SAS base I can use an OR statement or an IN(x1,x2,x3) statement to
>represent the union of several values. Is there an equivalent in macro
>language? I know there is no %OR or a %IN statement.
>
>Specifically I am running a %DO loop but on certain iterations I want
>something else executed.
>
>so for instance I have:
>
>%DO i=1 %TO 10;
>
> data xx&i;
> set x&i;
> %if &i=5 or &i=7 or &i=8 %then %do; /*need help on this line*/
> a=2*(age+10);
> %end;
> %else %do;
> a=age+10;
> %end;
> run;
>
>%end;
>
>Thanks!!!!
_________________________________________________________________
Get MSN 8 and help protect your children with advanced parental controls.
http://join.msn.com/?page=features/parental
|