| Date: | Fri, 12 Dec 2008 11:20:52 -0500 |
| Reply-To: | "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV> |
| Subject: | Re: Using macro variable in IF IN statement |
| In-Reply-To: | <2ed39ba2-ab90-4aba-854a-23a0278aa21f@n33g2000pri.googlegroups.com> |
| Content-Type: | text/plain; charset=us-ascii |
see also:
http://www.sascommunity.org/wiki/MINDELIMITER_Macro_In_Delimiter
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
> -----Original Message-----
> From: owner-sas-l@listserv.uga.edu
> [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of dmonder
> Sent: Thursday, December 11, 2008 3:59 PM
> To: sas-l@uga.edu
> Subject: Using macro variable in IF IN statement
>
> I would like to pass a list of values to a macro like follows:
>
> %MACRO Test( VarList );
>
> DATA MYDATA_NEW;
> SET MYDATA_OLD;
>
> IF ID IN (1,2,3,4,5)
> %If VarList~= & &VarList~=All %Then %Do;
> & MyVar IN (%SepList(&VarList)) /* <--- Here is
> where I want to use the list */
> %End;
> ;
> RUN;
> %* SepList can be found here:
> http://www.devenezia.com/downloads/sas/macros/index.php?m=seplist
> ;
>
> %MEND;
>
> Now I should be able to call my macro like:
> %Test( Value1 );
> %Test( Value1 Value2 );
>
> However, I get an error when I run this.
>
> NOTE 138-205: Line generated by the macro variable "EMIT".
> 1 Value1
> -------------
> 22
> ERROR 22-322: Syntax error, expecting one of the following: a quoted
> string, a numeric constant,
> a datetime constant, a missing value, iterator, (.
>
>
> Any idea how I might get this to work?
>
> Thanks!
> David
>
>
|