<?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: TRANSLATE function on multiple characters of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180623#M265135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where does the from variables come from? i.e. Shuffle provides the to part. &lt;/P&gt;&lt;P&gt;A loop like the following would work assuming the TO is in a variable similar to shuffle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; Have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;length&lt;/SPAN&gt; name $&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; TO_Shuffle= &lt;SPAN style="color: #942193;"&gt;"BCNJIWXYZ"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; FROM_SHUFFLE=&lt;SPAN style="color: #942193;"&gt;"DAVIONBEL"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;input&lt;/SPAN&gt; name $ ;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;datalines&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;DAVID&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;DON&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;ABEL&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;KANE&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/SPAN&gt; WANT;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;SET&lt;/SPAN&gt; HAVE;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;i=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;while&lt;/SPAN&gt; (scan(TO_shuffle, i) ne &lt;SPAN style="color: #942193;"&gt;""&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;to=scan(TO_shuffle, i);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;from=scan(FROM_shuffle, i);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;new_word=translate(NAME, to, from);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;i+&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Nov 2014 02:20:11 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-11-21T02:20:11Z</dc:date>
    <item>
      <title>TRANSLATE function on multiple characters of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180622#M265134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data Have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; length name $10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Shuffle= “BCNJIWXYZ”;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input name $ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;DAVID&lt;/P&gt;&lt;P&gt;DON&lt;/P&gt;&lt;P&gt;ABEL&lt;/P&gt;&lt;P&gt;KANE&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New variable called NEWNAME&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Translate all occurrences of “D” in name to “B”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “A” in name to “C”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “V” in name to “N”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “I” in name to “J”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “O” in name to “I”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “N” in name to “W”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “B” in name to “X”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “E” in name to “Y”&lt;/P&gt;&lt;P&gt;Translate all occurrences of “L” in name to “Z”&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: Translation is based on the variable Shuffle= “BCNJIWXYZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEWNAME for name=’DAVID’ will be ‘BCNJB’&lt;/P&gt;&lt;P&gt;NEWNAME for name=’DON’ will be ‘BIW’&lt;/P&gt;&lt;P&gt;NEWNAME for name=ABEL will be ‘CXYZ’&lt;/P&gt;&lt;P&gt;NEWNAME for name=KANE will be ‘KCWY’&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help with regards to this will be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 01:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180622#M265134</guid>
      <dc:creator>sas_null_</dc:creator>
      <dc:date>2014-11-21T01:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: TRANSLATE function on multiple characters of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180623#M265135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where does the from variables come from? i.e. Shuffle provides the to part. &lt;/P&gt;&lt;P&gt;A loop like the following would work assuming the TO is in a variable similar to shuffle.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; Have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;length&lt;/SPAN&gt; name $&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; TO_Shuffle= &lt;SPAN style="color: #942193;"&gt;"BCNJIWXYZ"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; FROM_SHUFFLE=&lt;SPAN style="color: #942193;"&gt;"DAVIONBEL"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;input&lt;/SPAN&gt; name $ ;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;datalines&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;DAVID&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;DON&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;ABEL&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;KANE&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;DATA&lt;/STRONG&gt;&lt;/SPAN&gt; WANT;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;SET&lt;/SPAN&gt; HAVE;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;i=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;while&lt;/SPAN&gt; (scan(TO_shuffle, i) ne &lt;SPAN style="color: #942193;"&gt;""&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;to=scan(TO_shuffle, i);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;from=scan(FROM_shuffle, i);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;new_word=translate(NAME, to, from);&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;i+&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 02:20:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180623#M265135</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-11-21T02:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: TRANSLATE function on multiple characters of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180624#M265136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;data Have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; length name $10;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; to= "BCNJIWXYZ";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; from="DAVIONBEL";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; input name $ ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; newname=translate(name, to, from);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; put name newname;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DAVID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DON&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABEL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;KANE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;DAVID BCNJB&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;DON BIW&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;ABEL CXYZ&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;KANE KCWY&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: be careful with the quote characters in your code. The right and left quotes used in your question are not understood by SAS. &lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 02:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180624#M265136</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-11-21T02:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: TRANSLATE function on multiple characters of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180625#M265137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ PGStat Thanks. Your answer works as well&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 15:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TRANSLATE-function-on-multiple-characters-of-a-variable/m-p/180625#M265137</guid>
      <dc:creator>sas_null_</dc:creator>
      <dc:date>2014-11-21T15:08:26Z</dc:date>
    </item>
  </channel>
</rss>

