<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find And Replace within a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45105#M9280</link>
    <description>&lt;P&gt;You can use &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p05ww22zp7lcg3n1bjk7v93tscyo.htm&amp;amp;locale=en" target="_self"&gt;translate function&lt;/A&gt;.&lt;BR /&gt; &lt;BR /&gt; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
 input x $40.;
 y=translate(x,' ','&amp;amp;');
cards;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon
Hello&amp;amp;World
Simon
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;x                   y

My&amp;amp;Name&amp;amp;Is&amp;amp;Simon    My Name Is Simon
Hello&amp;amp;World         Hello World     
Simon               Simon           
&lt;/PRE&gt;
&lt;P&gt;From &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13636"&gt;@sbb&lt;/a&gt;: For more than one character in a sequence, use &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0pgemqcslm9uen1tvr5gcrusgrw.htm&amp;amp;locale=en" target="_self"&gt;the TRANWRD function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;:&amp;nbsp;And since it looks like you might be trying to decode URL strings, &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p05qscijn2kj30n1ofetqnn8abob.htm&amp;amp;locale=en" target="_self"&gt;check out the URLDECODE function&lt;/A&gt; which handles your specific task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 infile datalines truncover;
 input text $40.;
 text=translate(text,' ','&amp;amp;');
 text=urldecode(text);
 put text;
datalines;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon
Simon%27s&amp;amp;World
%27 - '
%28 - (
%29 - )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;My Name Is Simon
Simon's World
' - '
( - (
) - )&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Mar 2017 12:33:59 GMT</pubDate>
    <dc:creator>yonib</dc:creator>
    <dc:date>2017-03-16T12:33:59Z</dc:date>
    <item>
      <title>Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45104#M9279</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I am trying to find a character within a string and replace it with something else, within the data step.&lt;BR /&gt;
For eg.&lt;BR /&gt;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon&lt;BR /&gt;
Hello&amp;amp;World&lt;BR /&gt;
Simon&lt;BR /&gt;
&lt;BR /&gt;
I want to replace the &amp;amp; with a space.&lt;BR /&gt;
&lt;BR /&gt;
I have tried a few of the macros available on here but they only seem to replace the first instance only.&lt;BR /&gt;
Any ideas?&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
Simon</description>
      <pubDate>Thu, 11 Sep 2008 10:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45104#M9279</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-11T10:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45105#M9280</link>
      <description>&lt;P&gt;You can use &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p05ww22zp7lcg3n1bjk7v93tscyo.htm&amp;amp;locale=en" target="_self"&gt;translate function&lt;/A&gt;.&lt;BR /&gt; &lt;BR /&gt; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
 input x $40.;
 y=translate(x,' ','&amp;amp;');
cards;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon
Hello&amp;amp;World
Simon
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;x                   y

My&amp;amp;Name&amp;amp;Is&amp;amp;Simon    My Name Is Simon
Hello&amp;amp;World         Hello World     
Simon               Simon           
&lt;/PRE&gt;
&lt;P&gt;From &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13636"&gt;@sbb&lt;/a&gt;: For more than one character in a sequence, use &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0pgemqcslm9uen1tvr5gcrusgrw.htm&amp;amp;locale=en" target="_self"&gt;the TRANWRD function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;:&amp;nbsp;And since it looks like you might be trying to decode URL strings, &lt;A href="http://go.documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p05qscijn2kj30n1ofetqnn8abob.htm&amp;amp;locale=en" target="_self"&gt;check out the URLDECODE function&lt;/A&gt; which handles your specific task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 infile datalines truncover;
 input text $40.;
 text=translate(text,' ','&amp;amp;');
 text=urldecode(text);
 put text;
datalines;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon
Simon%27s&amp;amp;World
%27 - '
%28 - (
%29 - )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;My Name Is Simon
Simon's World
' - '
( - (
) - )&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 12:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45105#M9280</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2017-03-16T12:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45106#M9281</link>
      <description>textVar2=translate(textVar,' ','&amp;amp;');&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Thu, 11 Sep 2008 10:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45106#M9281</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-09-11T10:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45107#M9282</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
Thanks for that...it works, but now have another problem....&lt;BR /&gt;
My string also contains other things i wanted to replace, like &lt;BR /&gt;
'%27' i want to replace with an apostrophe&lt;BR /&gt;
so my original string is&lt;BR /&gt;
Simon%27s&amp;amp;World&lt;BR /&gt;
&lt;BR /&gt;
translate works at replacing the &amp;amp; but i tried&lt;BR /&gt;
translate(translate(title,' ','&amp;amp;'),"%27","'")&lt;BR /&gt;
but it still only replces the &amp;amp;&lt;BR /&gt;
Help would be much appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Fri, 12 Sep 2008 11:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45107#M9282</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-12T11:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45108#M9283</link>
      <description>in fact i have half a dozen replacements to do:&lt;BR /&gt;
%27 - '&lt;BR /&gt;
%28 - (&lt;BR /&gt;
%29 - )&lt;BR /&gt;
and a few others... any ideas?&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
      <pubDate>Fri, 12 Sep 2008 11:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45108#M9283</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-12T11:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45109#M9284</link>
      <description>Use the TRANWRD function - similar to TRANSLATE.&lt;BR /&gt;
&lt;BR /&gt;
Refer to SAS Language DOC at the link below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 TRANWRD DOC:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a000215027.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/59540/HTML/default/a000215027.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.1 DOC:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/onlinedoc/91pdf/index.html" target="_blank"&gt;http://support.sas.com/documentation/onlinedoc/91pdf/index.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
SAS DOC main page (choose your SAS component and version):&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/index.html" target="_blank"&gt;http://support.sas.com/documentation/index.html&lt;/A&gt;</description>
      <pubDate>Fri, 12 Sep 2008 12:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45109#M9284</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-09-12T12:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45110#M9285</link>
      <description>Perfect thanks!!</description>
      <pubDate>Fri, 12 Sep 2008 14:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45110#M9285</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-09-12T14:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find And Replace within a string:</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45111#M9286</link>
      <description>Hi Simon&lt;BR /&gt;
&lt;BR /&gt;
Looks like URL escape syntax.&lt;BR /&gt;
Try this - it should also cover cases which might not yet be in your current data:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  infile datalines truncover;&lt;BR /&gt;
  input text $40.;&lt;BR /&gt;
  text=translate(text,' ','&amp;amp;');&lt;BR /&gt;
  text=urldecode(text);&lt;BR /&gt;
  put text;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
My&amp;amp;Name&amp;amp;Is&amp;amp;Simon&lt;BR /&gt;
Simon%27s&amp;amp;World&lt;BR /&gt;
%27 - '&lt;BR /&gt;
%28 - (&lt;BR /&gt;
%29 - )&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001191534.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a001191534.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Sat, 13 Sep 2008 08:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-And-Replace-within-a-string/m-p/45111#M9286</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-09-13T08:08:28Z</dc:date>
    </item>
  </channel>
</rss>

