<?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 spaces in character variable with point in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346987#M80073</link>
    <description>&lt;P&gt;Yes. Fortunately it's very easy. The translate function does it, but the order of the paramater&amp;nbsp;is odd. The second parameter is what you want the variable changed to, and the third is what you want it changed from.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length before after $ 10;
do i = 1 to 15;
   do j = 1 to 10;
      if ranuni(225465114) &amp;lt; .15
         then substr(before, j, 1) = ' ';
         else substr(before, j, 1) = byte(int(ranuni(225465114) * 26) + 1 + 64);
      end;
   after = translate(before, '.', ' ');
   put (before after) ($quote10. +2);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&lt;EM&gt;else&lt;/EM&gt; line is randomly populating a ten-character field with capital letters, but there's a 15% chance (previous line) that it'll be a space instead.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 10:37:11 GMT</pubDate>
    <dc:creator>LaurieF</dc:creator>
    <dc:date>2017-04-04T10:37:11Z</dc:date>
    <item>
      <title>replace spaces in character variable with point</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346975#M80065</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to replace the missing (spaces) in character variable with . (dot).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to do this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 10:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346975#M80065</guid>
      <dc:creator>ari</dc:creator>
      <dc:date>2017-04-04T10:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: replace spaces in character variable with point</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346982#M80069</link>
      <description>&lt;P&gt;If the original variable is 5 characters long, do you want 1 dot or 5 dots? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is text in the variable, but the text includes some blanks, do you want to replace those blanks too?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 10:27:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346982#M80069</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-04T10:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: replace spaces in character variable with point</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346987#M80073</link>
      <description>&lt;P&gt;Yes. Fortunately it's very easy. The translate function does it, but the order of the paramater&amp;nbsp;is odd. The second parameter is what you want the variable changed to, and the third is what you want it changed from.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length before after $ 10;
do i = 1 to 15;
   do j = 1 to 10;
      if ranuni(225465114) &amp;lt; .15
         then substr(before, j, 1) = ' ';
         else substr(before, j, 1) = byte(int(ranuni(225465114) * 26) + 1 + 64);
      end;
   after = translate(before, '.', ' ');
   put (before after) ($quote10. +2);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&lt;EM&gt;else&lt;/EM&gt; line is randomly populating a ten-character field with capital letters, but there's a 15% chance (previous line) that it'll be a space instead.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 10:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346987#M80073</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-04-04T10:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: replace spaces in character variable with point</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346997#M80079</link>
      <description>&lt;P&gt;A good idea is to always post test data in the form of a datastep and what you want the output to look like so we avoid guessing certain things.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 10:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-spaces-in-character-variable-with-point/m-p/346997#M80079</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-04T10:51:44Z</dc:date>
    </item>
  </channel>
</rss>

