<?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: Delete letters/numbers from the observation in a particular variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157345#M263002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply but I did not get you, what exactly you mean.&lt;/P&gt;&lt;P&gt;As such I could not understand the comparison and I am trying to delete those records containing these string 'e', 'f'', 'd'.&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jan 2014 17:26:22 GMT</pubDate>
    <dc:creator>Dipu</dc:creator>
    <dc:date>2014-01-30T17:26:22Z</dc:date>
    <item>
      <title>Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157343#M263000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Can please guide me-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the dataset with 20 variables and thousands of records-&lt;/P&gt;&lt;P&gt;One of the variable name- &lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;VAR1&lt;/SPAN&gt; contains--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;e&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;ased&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;egf&lt;/P&gt;&lt;P&gt;dgh&lt;/P&gt;&lt;P&gt;cedh&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;continued 1000's of records&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to delete the records containing any of these three letters 'e', 'f', 'd'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I used this- (as shown below), I could delete only records with only&amp;nbsp; 'e', 'f', 'd', I want to all the records containing these three letters- they may individual or in a group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data DM2;&lt;/P&gt;&lt;P&gt;set&amp;nbsp;&amp;nbsp; DM1;&lt;/P&gt;&lt;P&gt;if VAR1 in ( 'E', 'F', 'D') then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157343#M263000</guid>
      <dc:creator>Dipu</dc:creator>
      <dc:date>2014-01-30T17:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157344#M263001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at the index and find functions as a starting point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right now you're doing an exact comparison, but you want to search the string really.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157344#M263001</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-30T17:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157345#M263002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply but I did not get you, what exactly you mean.&lt;/P&gt;&lt;P&gt;As such I could not understand the comparison and I am trying to delete those records containing these string 'e', 'f'', 'd'.&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157345#M263002</guid>
      <dc:creator>Dipu</dc:creator>
      <dc:date>2014-01-30T17:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157346#M263003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if index(lowcase(var1), "e") or index(lowcase(var1), "f") or index(lowcase(var1), "d") then delete;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure there's a shorter way, but this is all I could think of on the spot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157346#M263003</guid>
      <dc:creator>pflickner</dc:creator>
      <dc:date>2014-01-30T17:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157347#M263004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the FINDC function.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002264923.htm" title="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002264923.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;findc(var1, "efd", 'it')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var1 - your variable to check&lt;/P&gt;&lt;P&gt;"efd" the characters you're checking for&lt;/P&gt;&lt;P&gt;'it' - modifiers, tells SAS to ignore case when checking (Characters are case sensitive, ie E does not equal e) and to trim trailing blanks. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first example data set shows you what the findc function returns, and the Want data set shows you how to keep only obs of interest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input var1 $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;e&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;ased&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;egf&lt;/P&gt;&lt;P&gt;dgh&lt;/P&gt;&lt;P&gt;cedh&lt;/P&gt;&lt;P&gt;jag&lt;/P&gt;&lt;P&gt;hat&lt;/P&gt;&lt;P&gt;sat&lt;/P&gt;&lt;P&gt;car&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 example;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;var2=findc(var1, "efd", 'it');&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if findc(var1, "efd", 'it')=0;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157347#M263004</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-30T17:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157348#M263005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;You're a treasure!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157348#M263005</guid>
      <dc:creator>pflickner</dc:creator>
      <dc:date>2014-01-30T17:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157349#M263006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course Reeza is more official, this is what those functions(findc, find, index, PRXs) made for. However, your question prompted me a unconventional usage of another function: compress():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input var1 $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;e&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;ased&lt;/P&gt;&lt;P&gt;f&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;egf&lt;/P&gt;&lt;P&gt;dgh&lt;/P&gt;&lt;P&gt;cedh&lt;/P&gt;&lt;P&gt;jag&lt;/P&gt;&lt;P&gt;hat&lt;/P&gt;&lt;P&gt;sat&lt;/P&gt;&lt;P&gt;car&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;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lengthn(var1) = lengthn(compress(var1,'efd','i'));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note, even this works for you, I would still recommend&amp;nbsp; Reeza's solution, which involves less functions and supposedly more efficient. My solution is FWIW only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 18:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157349#M263006</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-01-30T18:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157350#M263007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also found another function, VERIFY, that I hadn't seen before. I'll have to test it first before suggesting it though &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 18:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157350#M263007</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-30T18:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157351#M263008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Rizza, Pflickner and Hai.Kuo. &lt;/P&gt;&lt;P&gt;Than you So much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dipu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 18:43:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157351#M263008</guid>
      <dc:creator>Dipu</dc:creator>
      <dc:date>2014-01-30T18:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Delete letters/numbers from the observation in a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157352#M263009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An easier way to use compress, with the K (=keep) parameter:&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing (compress(var1,'efd','K'));&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Not tested&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jan 2014 08:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-letters-numbers-from-the-observation-in-a-particular/m-p/157352#M263009</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2014-01-31T08:38:17Z</dc:date>
    </item>
  </channel>
</rss>

