<?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: Substring based on specific criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795113#M255007</link>
    <description>&lt;PRE&gt;data have;
input VAR1 $ 1-50;
datalines;
This is row 1 (row1)           
This is row 2 (I think) (row2) 
(row3.)                        
;

data want;
 set have;  
 if substr(var1,length(var1))=')' then want=scan(var1,-1,'() ');
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Feb 2022 07:42:03 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-02-09T07:42:03Z</dc:date>
    <item>
      <title>Substring based on specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795062#M254981</link>
      <description>&lt;P&gt;I have the following date rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR1&lt;/P&gt;&lt;P&gt;This is row 1 (row1)&lt;/P&gt;&lt;P&gt;This is row 2 (I think) (row2)&lt;/P&gt;&lt;P&gt;(row3.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I need it to look like this:&lt;/P&gt;&lt;P&gt;row1&lt;/P&gt;&lt;P&gt;row2&lt;/P&gt;&lt;P&gt;row3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I need to trim the string into the text in between the last parenthesis. Can anyone help with code to perform this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 20:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795062#M254981</guid>
      <dc:creator>SAS_Muggle</dc:creator>
      <dc:date>2022-02-08T20:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Substring based on specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795067#M254983</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VAR1 $ 1-50;
datalines;
This is row 1 (row1)           
This is row 2 (I think) (row2) 
(row3.)                        
;

data want;
   if _N_=1 then r = prxparse('/\(([^)]*)\)[^(]*$/');
   set have;
   if prxmatch(r, VAR1) then var2 = prxposn(r, 1, VAR1);
   
   retain r;
   drop r;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;VAR1                            var2
This is row 1 (row1)            row1
This is row 2 (I think) (row2)  row2
(row3.)                         row3.&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Feb 2022 20:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795067#M254983</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-08T20:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Substring based on specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795113#M255007</link>
      <description>&lt;PRE&gt;data have;
input VAR1 $ 1-50;
datalines;
This is row 1 (row1)           
This is row 2 (I think) (row2) 
(row3.)                        
;

data want;
 set have;  
 if substr(var1,length(var1))=')' then want=scan(var1,-1,'() ');
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 07:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795113#M255007</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-02-09T07:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Substring based on specific criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795114#M255008</link>
      <description>&lt;P&gt;Done with SCAN and COMPRESS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1 $80.;
datalines;
This is row 1 (row1)
This is row 2 (I think) (row2)
(row3.)
;

data want;
set have;
var2 = compress(scan(var1,-1,"("),").");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Feb 2022 08:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substring-based-on-specific-criteria/m-p/795114#M255008</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-09T08:13:16Z</dc:date>
    </item>
  </channel>
</rss>

