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 (October 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 28 Oct 2005 11:34:35 -0400
Reply-To:     Chris Brooks <Chris.Brooks@ONS.GOV.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chris Brooks <Chris.Brooks@ONS.GOV.UK>
Subject:      Re: Searching macrovar for a comma

Steve

If I've interpreted the problem correctly and you have SAS 9 you could use the countc function like this

%macro comchk(string);

%let numcommas=%sysfunc(countc(&string,',')); %put &numcommas; %mend;

%comchk(%str(utc,8,,t));

Chris

Chris Brooks Office for National Statistics United Kingdom

On Fri, 28 Oct 2005 10:02:30 -0400, Steve Raimi <steven.raimi@GM.COM> wrote:

>I'm trying to add some error-trapping in a macro to make sure the user >doesn't use commas or other reserved characters in a list that should be >space-delimited. I think %sysfunc(indexc(source,excerpt-1<,excerpt- >2...excerpt-n>)) is the right way to go, but indexc allows multiple test >excerpts, and will interpret any comma as delimiting the list of excerpts. > >It seems to be a Catch-22. Within %sysfunc, function arguments that would >otherwise be quoted have to forego the quotation marks. Macro quoting >functions will unprotect the comma character when exposed to the indexc >function, which will then interpret it as indicating another excerpt will >be supplied (not as part of an excerpt to be tested). Without any special >handling, comma will also be interpreted that way. > >I'm sure I'm not the first to encounter this problem, but I can't find an >answer in the archives. Can someone help? > >TIA, >Steve Raimi


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