<?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: conditionally deleting part of an entry in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208585#M4821</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ran your code and got the result that I wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was just wandering, is it possible to generalize your code so that it can delete any given last numbers?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 04 May 2015 05:26:22 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2015-05-04T05:26:22Z</dc:date>
    <item>
      <title>conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208581#M4817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;suppose I have the following entries:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); width: 222px; height: 120px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;entry&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1234510&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;8765420&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;457BH10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;6g338k&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to get is the following: if the last 2 characters of the entry are either 10 or 20, then delete these two characters so that the final result is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="124" style="border: 1px solid rgb(0, 0, 0); width: 221px; height: 113px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;entry&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;12345&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;87654&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;457BH&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;6g338k&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 May 2015 20:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208581#M4817</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-05-03T20:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208582#M4818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input string $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length want $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; want=prxchange('s/([12]0)[[:blank:]]*$//o',1,string);&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1234510&lt;/P&gt;&lt;P&gt;8765420&lt;/P&gt;&lt;P&gt;457BH10&lt;/P&gt;&lt;P&gt;6g338k&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 May 2015 20:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208582#M4818</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-05-03T20:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208583#M4819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if substr(entry,length(entry)-1) in ('10','20') then entry=substr(entry,1,length(entry)-2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 May 2015 21:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208583#M4819</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-03T21:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208584#M4820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi sas@stat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran your code but unfortunately the new "entry" column was all empty ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 05:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208584#M4820</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-05-04T05:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208585#M4821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ran your code and got the result that I wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was just wandering, is it possible to generalize your code so that it can delete any given last numbers?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 05:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208585#M4821</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2015-05-04T05:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208586#M4822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could embed it in a user defined function (PROC FCMP), and thus make it easy to send parameters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 07:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208586#M4822</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-05-04T07:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208587#M4823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess we would need to generate the Regular Expression but if it's as simple as just a list of a few digits then this shouldn't be too hard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some code like below would do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data list;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length str $3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; str='10';output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; str='20';output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; str='38k';output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select strip(str) into :rem_list separated by '|'&lt;/P&gt;&lt;P&gt;&amp;nbsp; from list&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%put rem_list: &amp;amp;rem_list;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input string $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length want $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; want=prxchange("s/(&amp;amp;rem_list)[[:blank:]]*$//o",1,string);&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1234510&lt;/P&gt;&lt;P&gt;8765420&lt;/P&gt;&lt;P&gt;457BH10&lt;/P&gt;&lt;P&gt;457BH30&lt;/P&gt;&lt;P&gt;6g338k&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 08:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208587#M4823</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-05-04T08:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208588#M4824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must have made an error, look at the log.&lt;/P&gt;&lt;P&gt;This code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards;&lt;/P&gt;&lt;P&gt;input entry: $7.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1234510&lt;/P&gt;&lt;P&gt;8765420&lt;/P&gt;&lt;P&gt;457BH10&lt;/P&gt;&lt;P&gt;6g338k&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if substr(entry,length(entry)-1) in ('10','20') then entry=substr(entry,1,length(entry)-2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=have;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;/P&gt;&lt;P&gt;run;&lt;/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D&gt;457BH &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt; 4 &lt;/TD&gt;&lt;TD&gt;6g338k&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 10:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208588#M4824</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-05-04T10:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: conditionally deleting part of an entry</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208589#M4825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check it again as &lt;A __default_attr="828210" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; mentioned above. This works for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 May 2015 11:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/conditionally-deleting-part-of-an-entry/m-p/208589#M4825</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-05-04T11:23:09Z</dc:date>
    </item>
  </channel>
</rss>

