<?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: Insert space between Char and Numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633369#M187892</link>
    <description>&lt;P&gt;That's exactly what I asked for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 19 Mar 2020 17:54:38 GMT</pubDate>
    <dc:creator>Krauss</dc:creator>
    <dc:date>2020-03-19T17:54:38Z</dc:date>
    <item>
      <title>Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633336#M187878</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At first sight, it could seems to be an easy question, but i can't solve it.&lt;/P&gt;&lt;P&gt;In a string I could have something like this:&lt;/P&gt;&lt;P&gt;Have:&amp;nbsp; street flowers4 nowhere&amp;nbsp; &amp;nbsp; &amp;nbsp; want: street flowers 4 nowhere&lt;/P&gt;&lt;P&gt;Have:&amp;nbsp; 4Avenue10 nowhere&amp;nbsp; &amp;nbsp; &amp;nbsp; want: 4 Avenue 10 nowhere&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Resuming, insert a space when there's a sequence char/numeric or numeric/char.&lt;/P&gt;&lt;P&gt;How can I do this if don't know the position where it may occur?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;K&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 16:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633336#M187878</guid>
      <dc:creator>Krauss</dc:creator>
      <dc:date>2020-03-19T16:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633359#M187885</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303353"&gt;@Krauss&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it's easier to handle the two cases separately, e.g. like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input c $50.;
cards;
street flowers4 nowhere
4Avenue10 nowhere
;

data want;
set have;
c=prxchange('s/([^\d\s])(\d)/$1 $2/', -1, c);
c=prxchange('s/(\d)([^\d\s])/$1 $2/', -1, c);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The regular expression &lt;FONT face="courier new,courier"&gt;[^\d\s]&lt;/FONT&gt; means "not a digit or&amp;nbsp;whitespace character." You may want to change it to something else, for example to &lt;FONT face="courier new,courier"&gt;[[:alpha:]]&lt;/FONT&gt; if your definition of "Char" does not include punctuation marks, but only alphabetic characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 17:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633359#M187885</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-03-19T17:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633364#M187888</link>
      <description>&lt;P&gt;Use regular expressions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat line $64.;
input line &amp;amp;;
datalines;
street flowers4 nowhere
4Avenue10 nowhere
;
 
data want;
set have;
length newLine $128;
newLine = compbl(prxChange("s/(\d+)/ \1 /o", -1, line));
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 17:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633364#M187888</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-03-19T17:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633369#M187892</link>
      <description>&lt;P&gt;That's exactly what I asked for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 17:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633369#M187892</guid>
      <dc:creator>Krauss</dc:creator>
      <dc:date>2020-03-19T17:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633370#M187893</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 17:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633370#M187893</guid>
      <dc:creator>Krauss</dc:creator>
      <dc:date>2020-03-19T17:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633427#M187903</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/303353"&gt;@Krauss&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That's exactly what I asked for!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not exactly, I'd say: For example, your second test string gets indented by one character because a blank is inserted left to the "4" although there was no "char" justifying this insertion ("insert a space when there's a sequence &lt;STRONG&gt;char&lt;/STRONG&gt;/numeric or numeric/char"). But, of course, this is not a big issue and PG's solution is elegant (as always) in that it requires only a single assignment statement.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 20:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633427#M187903</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-03-19T20:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Insert space between Char and Numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633452#M187912</link>
      <description>&lt;P&gt;Yes &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;, good point. I have taken liberties with OP stated requirements. But then, those might not be exactly what is really required! I guess you might want to use &lt;STRONG&gt;left(compbl(...))&lt;/STRONG&gt; if you never want leading spaces.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2020 22:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-space-between-Char-and-Numeric/m-p/633452#M187912</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-03-19T22:57:21Z</dc:date>
    </item>
  </channel>
</rss>

