<?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: How to remove all text before or after a specific character, e.g., all text after a comma in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850833#M336233</link>
    <description>&lt;P&gt;Yes, that's it. But now I'm confused, I don't think the Find and Replace dialog box in SAS 9.4 matches what is shown at that link, so I still don't know how to answer the question.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Dec 2022 18:48:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-12-22T18:48:42Z</dc:date>
    <item>
      <title>How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850820#M336229</link>
      <description>&lt;P&gt;For a variable, I want to remove all text after a question mark (?) and for another variable, I want to remove all text before a space ( ). I know how to do it in Excel like the following note for a comma, for example. But I do not know that in SAS. Thanks for your help&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marysasfan_0-1671731058575.png" style="width: 772px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78814iCBAF46E12BB1444E/image-dimensions/772x245?v=v2" width="772" height="245" role="button" title="marysasfan_0-1671731058575.png" alt="marysasfan_0-1671731058575.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.extendoffice.com/documents/excel/1783-excel-remove-text-before-character.html" target="_blank"&gt;https://www.extendoffice.com/documents/excel/1783-excel-remove-text-before-character.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 17:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850820#M336229</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2022-12-22T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850827#M336230</link>
      <description>&lt;P&gt;What SAS interface are you talking about? Base SAS? SAS Enterprise Guide? Something else?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 18:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850827#M336230</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-22T18:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850830#M336231</link>
      <description>&lt;P&gt;I use SAS 9.4 for windows. Does this answer your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 18:33:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850830#M336231</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2022-12-22T18:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850833#M336233</link>
      <description>&lt;P&gt;Yes, that's it. But now I'm confused, I don't think the Find and Replace dialog box in SAS 9.4 matches what is shown at that link, so I still don't know how to answer the question.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 18:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850833#M336233</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-22T18:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850834#M336234</link>
      <description>&lt;P&gt;I am looking for a line of code or SAS syntax that can do a similar data cleaning for me in SAS. Currently, I have to send my data to Excel, do this step, and read it again in SAS. I want to be able to do this in SAS. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 18:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850834#M336234</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2022-12-22T18:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850839#M336237</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am looking for a line of code or SAS syntax that can do a similar data cleaning for me in SAS.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To remove text before a blank space&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want1 = substr(text_string1, find(text_string1,'&amp;nbsp;')+1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Remove text after a question mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want2 = scan(tex_string2,1,'?');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Dec 2022 19:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850839#M336237</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-22T19:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850851#M336242</link>
      <description>&lt;P&gt;Are you asking about how to edit your program? If so then what is the use case where it makes any sense to try to automatic modifying code in that way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not then why are you talking about a GUI tool like the find/replace tool of Excel?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are talking about modifying data then just use CODE to make the changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SCAN() is useful for finding text up to particular character.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;beginning=scan(string,1,',');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if the string does not have any commas then you get the whole string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For finding text after a character you probably want to use FIND() or INDEX() to locate the first occurence of the character and then use SUBSTR().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ending=substr(string,index(string,',')+1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Again if there are no commas then it will return the whole string.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 19:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850851#M336242</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-22T19:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove all text before or after a specific character, e.g., all text after a comma</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850853#M336244</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;for taking the time to check my question. Your suggestions for using&amp;nbsp;substr and scan does exactly what I was looking for. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 19:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-all-text-before-or-after-a-specific-character-e-g/m-p/850853#M336244</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2022-12-22T19:59:34Z</dc:date>
    </item>
  </channel>
</rss>

