Date: Fri, 14 Jun 2002 19:09:30 -0400
Reply-To: Don Henderson <donaldjhenderson@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Don Henderson <donaldjhenderson@HOTMAIL.COM>
Subject: Re: replace question
Content-Type: text/plain; charset="iso-8859-1"
Crystal,
If I recall correctly, you have asked about web based and IntrNet questions
a number of times. If so, perhaps an alternative to Matt's suggestion might
be appropriate. Typcially in web apps you need to urlencode blanks and that
is often accomplished by replacing them with a + sign. However you can also
replace blanks with a %20. Since there are a number of characters other than
blanks that sometimes need to be encoded in web apps, you might want to
consider using the urlencode function:
6 data a;
7 x='Harry Potter ';
8 y=urlencode(trim(x));
9 put x= y=;
10 run;
x=Harry Potter y=Harry%20Potter
It has the advantage of encoding not only blanks, but it also encodes the
other special characters that you might encounter in your data. Note however
that it has been reported on the list that the urlencode (and there is also
a urldecode function) function is only shipped with IntrNet.
If you just need to replace blanks with +'s, then Matts example (assuming
you trim it inside the translate function call so trailing blanks don't get
converted) should be fine.
HTH,
Don Henderson
----- Original Message -----
From: "Matthew Ness" <MNess@CROMEDICA.COM>
Newsgroups: bit.listserv.sas-l
To: <SAS-L@LISTSERV.UGA.EDU>
Sent: Friday, June 14, 2002 3:45 PM
Subject: Re: replace question
> Hi Crystal,
>
> data a;
> x='Harry Potter';
> y=translate(x,'+',' ');
> run;
>
> Cheers,
> Matt
>
>
>
>
>
> Crystal
> Vierhout To: SAS-L@LISTSERV.UGA.EDU
> <vierhout@UNITY cc:
> .NCSU.EDU> Subject: replace question
> Sent by:
> "SAS(r)
> Discussion"
> <SAS-L@LISTSERV
> .UGA.EDU>
>
>
> 14/06/02 12:37
> PM
> Please respond
> to Crystal
> Vierhout
>
>
>
>
>
>
> Hello,
>
> Does anyone know an simple way to replace a
>
> Harry Potter with a Harry+Potter
>
>
> I need to replace the space with a +. This has to be simple.
>
>
> Crystal Vierhout
> Dairy Records Management Systems
>
|