<?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 Get string between parenthesis only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859925#M339714</link>
    <description>&lt;P&gt;Hi, I'm trying to get a string between parenthesis when there are characters before and after the parenthesis.&amp;nbsp; The string looks like this:&amp;nbsp;GGT (U/L)&amp;nbsp; &amp;nbsp; 1 - 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the output to be this:&amp;nbsp;U/L&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2023 14:46:43 GMT</pubDate>
    <dc:creator>jmmedina252</dc:creator>
    <dc:date>2023-02-21T14:46:43Z</dc:date>
    <item>
      <title>Get string between parenthesis only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859925#M339714</link>
      <description>&lt;P&gt;Hi, I'm trying to get a string between parenthesis when there are characters before and after the parenthesis.&amp;nbsp; The string looks like this:&amp;nbsp;GGT (U/L)&amp;nbsp; &amp;nbsp; 1 - 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the output to be this:&amp;nbsp;U/L&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 14:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859925#M339714</guid>
      <dc:creator>jmmedina252</dc:creator>
      <dc:date>2023-02-21T14:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get string between parenthesis only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859928#M339717</link>
      <description>&lt;P&gt;Assuming there is only one left parenthesis and one right parenthesis (is that a good assumption?)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    left=find(variablename,'(');
    right=find(variablename,')');
    desired_string=substr(variablename,left+1,right-left-1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 14:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859928#M339717</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-21T14:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get string between parenthesis only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859931#M339719</link>
      <description>&lt;P&gt;As long as parentheses are not the first character, you can use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;inside = scan(variable, 2, ')(');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This selects the second set of characters within the string, using parentheses as delimiters.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 15:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859931#M339719</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-02-21T15:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Get string between parenthesis only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859955#M339729</link>
      <description>&lt;P&gt;And easy enough to test if the ( is the first character:&lt;/P&gt;
&lt;PRE&gt;data example;
   input string $10.;
datalines;
GGT (U/L)  
(start) of
;

data want;
   set example;
   if string =:'(' then want= scan(string,1,'()');
   else want=scan(string,2,'()');
run;&lt;/PRE&gt;
&lt;P&gt;If you have not seen the =: that is basically a "begins with". So if the first character is ( then the first bit is grabbed, otherwise the second.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/859955#M339729</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-21T16:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get string between parenthesis only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/860134#M339816</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Assuming there is only one parenthesis*/
data example;
   input string $40.;
datalines;
GGT (U/L)    1 - 5
(start) of
;
data want;
 set example;
 pid=prxparse('/\(.*?\)/');
 call prxsubstr(pid,string,p,l);
 if p then want=compress(substr(string,p,l),'()');
 drop p l pid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2023 11:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-string-between-parenthesis-only/m-p/860134#M339816</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-02-22T11:50:17Z</dc:date>
    </item>
  </channel>
</rss>

