| Date: | Sat, 2 Aug 2003 09:34:06 -0400 |
| 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: Compress multiple spaces _outside_ quoted values ? |
|---|
"Richard A. DeVenezia" <radevenz@ix.netcom.com> wrote in message
news:bgdsa7$n6494$1@ID-168040.news.uni-berlin.de...
> I have a string containing multiple spaces, that typically would be
> compressed out using COMPBL. However, I don't want to remove multiple
spaces
> if they are within quotes.
>
> Any ideas how to achieve this ?
>
> --
> Richard A. DeVenezia
>
Put out a little bird seed and you get little birdies...
rxparse and rxchange
data a;
infile cards pad truncover ;
length string $100;
input string $ 1-100 ;
cards;
1 This is a test "should leave two spaces here" but not here
2 No double quotes in this string
3 Name = 'O''Connor, Mary' and Sex=" Female "
4 Comment = 'Agreed "in principal"'
5 Comment = 'Agreed "in principal"'
6 Comment = 'Agreed in principal'
7 Comment = 'Agreed in principal'
8 Comment = "Agreed ""in principal"""
9 Mismatched "double quotes in this string", what to do" with
it?, let it be part of the compressible stream
run;
data b;
set a;
if _n_=1 then do;
retain rx;
rx = rxparse(
'$q to ==,' || /* don't change quoted strings */
'$w+ to " ",' || /* change strings of white space to a blank */
'?#-1 to =='); /* don't change anything else */
end;
call rxchange( rx, 999, string);
run;
proc print; run;
--
Richard
|