<?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: Remove all Text before Comma in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603154#M174739</link>
    <description>&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;want=scan(Comment_variable,-1,',');&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Nov 2019 12:00:54 GMT</pubDate>
    <dc:creator>Sathish_jammy</dc:creator>
    <dc:date>2019-11-11T12:00:54Z</dc:date>
    <item>
      <title>Remove all Text before Comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603152#M174737</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a variable (Comments_Line) where by it's prefixed with text that I don't need and it always follows the same structure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to remove any text before the first comma and if possible, remove the comma too!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;An example of this would be:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Kevin,&lt;/STRONG&gt; welcome to your new account&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Abi,&lt;/STRONG&gt; we miss you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ideally what i would like to see on the examples used above would be the following output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;welcome to your new account&lt;/P&gt;
&lt;P&gt;we miss you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea is this is possible please and if it is, how I would go about doing this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 11:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603152#M174737</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-11-11T11:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all Text before Comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603154#M174739</link>
      <description>&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;want=scan(Comment_variable,-1,',');&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 12:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603154#M174739</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-11-11T12:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all Text before Comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603157#M174740</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;A id="link_18" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215282" target="_self"&gt;&lt;SPAN class="login-bold"&gt;Sathish_jammy&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 12:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603157#M174740</guid>
      <dc:creator>KC_16</dc:creator>
      <dc:date>2019-11-11T12:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all Text before Comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603158#M174741</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Comments_Line $ 1-100;
infile datalines truncover;
datalines;
Kevin, welcome to your new account
Abi, we miss you
;

data want;
    set have;
    NewVar=scan(Comments_Line,-1,',');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Comments_Line                      NewVar
Kevin, welcome to your new account welcome to your new account
Abi, we miss you                   we miss you&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Nov 2019 12:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603158#M174741</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-11T12:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Remove all Text before Comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603256#M174791</link>
      <description>&lt;P&gt;There are some boundary conditions your example test data don't cover.&amp;nbsp; What do you want when there are no commas? Comma is the FIRST character.&amp;nbsp; There are two or more commas?&lt;/P&gt;
&lt;P&gt;Here is your requirment.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I need to remove any text before the first comma and if possible, remove the comma too!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Here is code to do that for the variable named STRING in the dataset named HAVE.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  string=left(substrn(string,indexc(string,',')+1));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This will handle strings that start with comma, have no comma, and have multiple commas.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The SUBSTRN() will handle the case if the first comma is at the end of the variable so that adding one would be trying to index past the end of STRING.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The LEFT() function will remove space(s) that follow the comma.&amp;nbsp; Note this means that for strings without any commas&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;it will remove leading spaces.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 15:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-all-Text-before-Comma/m-p/603256#M174791</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-11T15:51:09Z</dc:date>
    </item>
  </channel>
</rss>

