<?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: Extracting text from string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719056#M222580</link>
    <description>&lt;P&gt;SCAN lets you specify your delimiters, try using all the digits and the opening parenthesis to see if that gives you what you need.&lt;BR /&gt;You can also look at the modifiers for slightly simpler code, but this &lt;STRIKE&gt;should&lt;/STRIKE&gt; works. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string_variable : &amp;amp; $40.;
cards;
Chocolate chips (2)
Brown sugar (1)
Eggs 3 
Flour (1) 
Butter 2 
;;;;
run;

data want;
set have;

want = scan(string_variable, 1, "01234567890(");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89165"&gt;@Krysia24&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have data that look like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chocolate chips (2)&lt;/P&gt;
&lt;P&gt;Brown sugar (1)&lt;/P&gt;
&lt;P&gt;Eggs 3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Flour (1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Butter 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what I want is just:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chocolate chips&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brown sugar&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eggs&lt;/P&gt;
&lt;P&gt;Flour&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Butter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I want to retain all text prior to a digit or special character without compressing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 23:48:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-12T23:48:32Z</dc:date>
    <item>
      <title>Extracting text from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719053#M222577</link>
      <description>&lt;P&gt;I have data that look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chocolate chips (2)&lt;/P&gt;&lt;P&gt;Brown sugar (1)&lt;/P&gt;&lt;P&gt;Eggs 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;Flour (1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Butter 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I want is just:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chocolate chips&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brown sugar&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eggs&lt;/P&gt;&lt;P&gt;Flour&amp;nbsp;&lt;/P&gt;&lt;P&gt;Butter&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I want to retain all text prior to a digit or special character without compressing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 23:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719053#M222577</guid>
      <dc:creator>Krysia24</dc:creator>
      <dc:date>2021-02-12T23:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719056#M222580</link>
      <description>&lt;P&gt;SCAN lets you specify your delimiters, try using all the digits and the opening parenthesis to see if that gives you what you need.&lt;BR /&gt;You can also look at the modifiers for slightly simpler code, but this &lt;STRIKE&gt;should&lt;/STRIKE&gt; works. &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string_variable : &amp;amp; $40.;
cards;
Chocolate chips (2)
Brown sugar (1)
Eggs 3 
Flour (1) 
Butter 2 
;;;;
run;

data want;
set have;

want = scan(string_variable, 1, "01234567890(");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89165"&gt;@Krysia24&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have data that look like this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chocolate chips (2)&lt;/P&gt;
&lt;P&gt;Brown sugar (1)&lt;/P&gt;
&lt;P&gt;Eggs 3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Flour (1)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Butter 2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And what I want is just:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chocolate chips&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brown sugar&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Eggs&lt;/P&gt;
&lt;P&gt;Flour&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Butter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I want to retain all text prior to a digit or special character without compressing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 23:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719056#M222580</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-12T23:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719061#M222585</link>
      <description>&lt;P&gt;Thank you! I was using a combination of substr and index and wasn't quite getting what I wanted. Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2021 00:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719061#M222585</guid>
      <dc:creator>Krysia24</dc:creator>
      <dc:date>2021-02-13T00:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719251#M222687</link>
      <description>&lt;P&gt;Another way is to COMPRESS out all the characters you don't want.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 00:36:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-text-from-string/m-p/719251#M222687</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-02-15T00:36:32Z</dc:date>
    </item>
  </channel>
</rss>

