<?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 'and' 'und' as &amp;amp; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-and-und-as-amp/m-p/540290#M149019</link>
    <description>&lt;P&gt;You should first make sure that your example code creates the values you want us to manipulate.&lt;/P&gt;
&lt;P&gt;Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data a;
  infile datalines dlm=',' truncover;
  informat COUNTRY_CODE $4. name $25.;
  input COUNTRY_CODE name  4-25 ;
datalines;
GB, apple and juicande
GB, apple und juicand
GE, plus und flundy
IT, jjeed e dinedd
run;&lt;/PRE&gt;
&lt;P&gt;Your example has country_code ending with , and the name blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second please show exactly what you want for output. Perhaps:&lt;/P&gt;
&lt;PRE&gt;data a;
  infile datalines dlm=',' truncover;
  informat COUNTRY_CODE $4. name $25.;
  input COUNTRY_CODE name  4-25 ;
  if  COUNTRY_CODE='GB' then name=tranwrd(name,' and ',' &amp;amp; ');
  if  COUNTRY_CODE='GE' then name=tranwrd(name,' und ',' &amp;amp; ');
datalines;
GB, apple and juicande
GB, apple und juicand
GE, plus und flundy
IT, jjeed e dinedd
run;&lt;/PRE&gt;
&lt;P&gt;Including the leading and trailing spaces for the words and or und and then including them in the replacement string seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 23:29:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-03-04T23:29:22Z</dc:date>
    <item>
      <title>replace 'and' 'und' as &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-and-und-as-amp/m-p/540283#M149013</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to replace 'AND' (if COUNTRY_CODE='GB'), 'UND'(if COUNTRY_CODE='GE'), 'E'(if&amp;nbsp;COUNTRY_CODE='IT') as '&amp;amp;'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;especially, replaced 'AND' should be a single word(i.e., it is 'a and b', rather than 'aandb' )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you please give me some suggestion about this?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  infile datalines dlm=',';
  input COUNTRY_CODE $4. name &amp;amp;25;
datalines;
GB, apple and juicande
GB, apple und juicand
GE, plus und flundy
IT, jjeed e dinedd
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2019 23:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-and-und-as-amp/m-p/540283#M149013</guid>
      <dc:creator>Alexxxxxxx</dc:creator>
      <dc:date>2019-03-04T23:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: replace 'and' 'und' as &amp;</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-and-und-as-amp/m-p/540290#M149019</link>
      <description>&lt;P&gt;You should first make sure that your example code creates the values you want us to manipulate.&lt;/P&gt;
&lt;P&gt;Perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data a;
  infile datalines dlm=',' truncover;
  informat COUNTRY_CODE $4. name $25.;
  input COUNTRY_CODE name  4-25 ;
datalines;
GB, apple and juicande
GB, apple und juicand
GE, plus und flundy
IT, jjeed e dinedd
run;&lt;/PRE&gt;
&lt;P&gt;Your example has country_code ending with , and the name blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second please show exactly what you want for output. Perhaps:&lt;/P&gt;
&lt;PRE&gt;data a;
  infile datalines dlm=',' truncover;
  informat COUNTRY_CODE $4. name $25.;
  input COUNTRY_CODE name  4-25 ;
  if  COUNTRY_CODE='GB' then name=tranwrd(name,' and ',' &amp;amp; ');
  if  COUNTRY_CODE='GE' then name=tranwrd(name,' und ',' &amp;amp; ');
datalines;
GB, apple and juicande
GB, apple und juicand
GE, plus und flundy
IT, jjeed e dinedd
run;&lt;/PRE&gt;
&lt;P&gt;Including the leading and trailing spaces for the words and or und and then including them in the replacement string seems to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 23:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-and-und-as-amp/m-p/540290#M149019</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-04T23:29:22Z</dc:date>
    </item>
  </channel>
</rss>

