<?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 every nth word with a nth word concatenated with a symbol in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231292#M42053</link>
    <description>Thank you Haikuo it was wonderful.</description>
    <pubDate>Fri, 23 Oct 2015 00:56:33 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2015-10-23T00:56:33Z</dc:date>
    <item>
      <title>replace every nth word with a nth word concatenated with a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231218#M42038</link>
      <description>&lt;P&gt;Dear Expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me concatenate every nth word with a symbol.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider that i have a string data like below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;"having a common variable to merge by ensures that the"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;the expected output should be &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="st"&gt;"having a common * variable to merge * by ensures that * the"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;So after every 3rd word i have to place the symbol(*). like above. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;Could you please suggest a solution. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="st"&gt;Jag&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 17:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231218#M42038</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-10-22T17:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: replace every nth word with a nth word concatenated with a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231228#M42039</link>
      <description>&lt;P&gt;Put the CATx functions to good use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length subStr outStr $200;
inStr = "having a common variable to merge by ensures that the";
do i = 1 by 3 until(Missing(subStr));
    subStr = catx(" ", scan(inStr,i), scan(inStr,i+1), scan(inStr,i+2));
    outStr = catx(" * ", outStr, subStr);
    end;
drop subStr i;
run;

proc print data=test noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Oct 2015 18:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231228#M42039</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-10-22T18:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: replace every nth word with a nth word concatenated with a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231231#M42040</link>
      <description>Thank you so much PG , it worked</description>
      <pubDate>Thu, 22 Oct 2015 18:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231231#M42040</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-10-22T18:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: replace every nth word with a nth word concatenated with a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231234#M42041</link>
      <description>&lt;P&gt;Here is another way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;
length outStr $200;
inStr = "having a common variable to merge by ensures that the";
outstr=prxchange('s/((\w+ ){3})/$1* /', -1, instr);
run;&lt;/PRE&gt;&lt;P&gt;This is to tell SAS adding * right after the 3rd word, in a literal sense.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Oct 2015 18:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231234#M42041</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-10-22T18:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: replace every nth word with a nth word concatenated with a symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231292#M42053</link>
      <description>Thank you Haikuo it was wonderful.</description>
      <pubDate>Fri, 23 Oct 2015 00:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replace-every-nth-word-with-a-nth-word-concatenated-with-a/m-p/231292#M42053</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2015-10-23T00:56:33Z</dc:date>
    </item>
  </channel>
</rss>

