<?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: replace a foreign character in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31063#M5960</link>
    <description>Don't use "quotes" 'quotes' in macro language.&lt;BR /&gt;
&lt;BR /&gt;
1632  %let old=ppø;&lt;BR /&gt;
1633  %let new=&amp;amp;old;&lt;BR /&gt;
1634&lt;BR /&gt;
1635  %let new = %sysfunc(tranwrd(&amp;amp;old, ø, aa));&lt;BR /&gt;
1636  %put NOTE &amp;amp;new;&lt;BR /&gt;
NOTE ppaa</description>
    <pubDate>Thu, 17 Mar 2011 13:55:52 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2011-03-17T13:55:52Z</dc:date>
    <item>
      <title>replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31054#M5951</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to replace a foreign character in a string, unfortunatelly most of useful string functions such as "tranwrd" does not work because SAS complains that it is not a valide SAS name. Right now, I created a macro. In the macro I get the length of the string, then use "substr" to get a single letter at a time, then do a cat afterwards.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have a better idea please?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Qun</description>
      <pubDate>Wed, 16 Mar 2011 09:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31054#M5951</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-16T09:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31055#M5952</link>
      <description>&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;options&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt; &lt;/SPAN&gt;&lt;SPAN class="SpellE"&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: blue; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;validvarname&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: black; background: none repeat scroll 0% 0% white;" lang="EN-US"&gt;=any;&lt;/SPAN&gt;&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Then you can use invalid sas varname.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 16 Mar 2011 09:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31055#M5952</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-16T09:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31056#M5953</link>
      <description>Share the actual SAS log with the specific error message revealed -- include all SAS program code revealed.  You can do this with a COPY/PASTE into your next forum post-reply.  &lt;BR /&gt;
&lt;BR /&gt;
Also add this statement to generate additional diagnostic message with all variable values displayed to the log:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Wed, 16 Mar 2011 13:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31056#M5953</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-16T13:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31057#M5954</link>
      <description>Many thanks, Ksharp. I should've looked at the options in the first place.&lt;BR /&gt;
&lt;BR /&gt;
Yan</description>
      <pubDate>Wed, 16 Mar 2011 13:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31057#M5954</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-16T13:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31058#M5955</link>
      <description>It is unclear to me what you mean by foreign character.  And if the characters are in variable values of variable names.  &lt;BR /&gt;
&lt;BR /&gt;
For values of variables check out COMPRESS.</description>
      <pubDate>Wed, 16 Mar 2011 15:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31058#M5955</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-16T15:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31059#M5956</link>
      <description>Hi. _null_&lt;BR /&gt;
For the foreign character, SAS has some specical function to process this situation.&lt;BR /&gt;
For example : Kcompress()&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 17 Mar 2011 03:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31059#M5956</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-17T03:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31060#M5957</link>
      <description>I am confused as why the following code didn't work as I expected&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
options validvarname=any; &lt;BR /&gt;
&lt;BR /&gt;
%macro test();&lt;BR /&gt;
	%global new;&lt;BR /&gt;
	%let old = ppø;&lt;BR /&gt;
	%let new = %sysfunc(tranwrd(&amp;amp;old, 'ø', 'aa'));&lt;BR /&gt;
	%put &amp;amp;new;&lt;BR /&gt;
%mend; &lt;BR /&gt;
&lt;BR /&gt;
%test();&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;new;&lt;BR /&gt;
&lt;BR /&gt;
The result is&lt;BR /&gt;
&lt;BR /&gt;
MLOGIC(TEST):  Beginning execution.&lt;BR /&gt;
MLOGIC(TEST):  %LET (variable name is NEW)&lt;BR /&gt;
SYMBOLGEN:  Macro variable OLD resolves to ppø&lt;BR /&gt;
MLOGIC(TEST):  %PUT &amp;amp;new&lt;BR /&gt;
SYMBOLGEN:  Macro variable NEW resolves to ppø&lt;BR /&gt;
ppø&lt;BR /&gt;
MLOGIC(TEST):  Ending execution.&lt;BR /&gt;
3832&lt;BR /&gt;
3833   %put &amp;amp;new;&lt;BR /&gt;
SYMBOLGEN:  Macro variable NEW resolves to ppø&lt;BR /&gt;
ppø&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I would thought "new" should be "ppaa".&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Many thanks,&lt;BR /&gt;
Qun</description>
      <pubDate>Thu, 17 Mar 2011 13:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31060#M5957</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-17T13:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31061#M5958</link>
      <description>Sorry, cut past the wrong code&lt;BR /&gt;
&lt;BR /&gt;
options validvarname=any; &lt;BR /&gt;
&lt;BR /&gt;
%let old=ppø;&lt;BR /&gt;
%let new=&amp;amp;old;&lt;BR /&gt;
&lt;BR /&gt;
%macro test();&lt;BR /&gt;
  %let new = %sysfunc(tranwrd(&amp;amp;old, 'ø', 'aa'));&lt;BR /&gt;
  %put &amp;amp;new;&lt;BR /&gt;
%mend; &lt;BR /&gt;
&lt;BR /&gt;
%test();&lt;BR /&gt;
&lt;BR /&gt;
%put &amp;amp;new;</description>
      <pubDate>Thu, 17 Mar 2011 13:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31061#M5958</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-17T13:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31062#M5959</link>
      <description>It's one of those issues with quote. Once I removed the quote around ø, and aa, it works.&lt;BR /&gt;
&lt;BR /&gt;
I can never be sure when I suppose to ", or ' in data step or in macro.&lt;BR /&gt;
&lt;BR /&gt;
Qun</description>
      <pubDate>Thu, 17 Mar 2011 13:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31062#M5959</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-17T13:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31063#M5960</link>
      <description>Don't use "quotes" 'quotes' in macro language.&lt;BR /&gt;
&lt;BR /&gt;
1632  %let old=ppø;&lt;BR /&gt;
1633  %let new=&amp;amp;old;&lt;BR /&gt;
1634&lt;BR /&gt;
1635  %let new = %sysfunc(tranwrd(&amp;amp;old, ø, aa));&lt;BR /&gt;
1636  %put NOTE &amp;amp;new;&lt;BR /&gt;
NOTE ppaa</description>
      <pubDate>Thu, 17 Mar 2011 13:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31063#M5960</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-17T13:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31064#M5961</link>
      <description>This is a good introduction to the SAS Macro facility:&lt;BR /&gt;
 &lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 17 Mar 2011 16:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31064#M5961</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-03-17T16:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: replace a foreign character in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31065#M5962</link>
      <description>Hi.&lt;BR /&gt;
_null_ is right .Macro facility treat anything as text ,even if it is the argument of function.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 18 Mar 2011 02:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-a-foreign-character-in-a-string/m-p/31065#M5962</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-18T02:55:36Z</dc:date>
    </item>
  </channel>
</rss>

