Date: Thu, 10 Feb 2005 14:15:41 -0500
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: Howto Parse Macro Variable Into Variables Delimited By Speech
Marks
ben.powell@CLA.CO.UK wrote:
> Dear SAS-L
>
> I have an extract macro that takes a text variable that can either by
> missing (not entered) and hence equal to ""; a single two character
> string e.g. XX; or multiple two character strings e.g. XX YY ZZ.
>
> I want to pass that macro variable to an sql query where clause. I've
> incorporated error handling so the query only fires if the string ^ =
> "" but inorder to search on each of the two char strings they must be
> delimited by speechmarks.
>
If I understand, this would work.
Assuming callee honors the contract for text.
%let text = XX YY ZZ AA;
%let inclause = "%sysfunc (TRANWRD(&text,%str( )," "))";
%put &text;
%put &inclause;
XX YY ZZ AA
"XX" "YY" "ZZ" "AA"
for safety you might want to COMPBL before TRANWRD.
--
Richard A. DeVenezia
http://www.devenezia.com/