<?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: How to find the observation which has specific character and then remove it? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389426#M66044</link>
    <description>&lt;P&gt;Because you also said:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;And I need a list of deleted observation from dataset.&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Aug 2017 23:23:37 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-20T23:23:37Z</dc:date>
    <item>
      <title>How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389422#M66040</link>
      <description>&lt;P&gt;Hello everybody;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a variable that contains alphanumeric strings of specific lengths,&amp;nbsp;for&amp;nbsp;example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Name variable:&lt;BR /&gt;asdf1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;asdg2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;zxcv4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;asdh3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;qwer2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;rtyu4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;xcvb4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now, I want to delete observations which have '4' in its name, for instance&amp;nbsp;zxcv4. So, the result is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Name variable:&lt;BR /&gt;asdf1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;asdg2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;asdh3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;qwer2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And I need a&amp;nbsp;list of deleted observation from dataset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the attributes of the&amp;nbsp;TRD_STCK_CD variable in my dataset as the name variable.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alphabetic List of Variables and Attributes&lt;/P&gt;&lt;P&gt;# Variable Type Len Format Informat Label&lt;/P&gt;&lt;P&gt;1 TRD_STCK_CD Char 15 $15. $15. TRD_STCK_CD&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2017 22:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389422#M66040</guid>
      <dc:creator>aminkarimid</dc:creator>
      <dc:date>2017-08-20T22:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389423#M66041</link>
      <description>&lt;P&gt;FIND() will find character, FINDW() will search for a word.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are also INDEX and INDEXW() functions that operate similarily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather than 'delete' you can control where an observation is output to using an OUTPUT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example using SASHELP.CLASS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data females males;
set sashelp.class;

if sex='F' then output females;
else if sex='M' then output males;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Aug 2017 22:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389423#M66041</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-20T22:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389424#M66042</link>
      <description>Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1991"&gt;@Reza&lt;/a&gt;;&lt;BR /&gt;I do not know why do you recommend 'output' statement.&lt;BR /&gt;I want to remove these data from my dataset in data cleaning procedure&lt;BR /&gt;related to my research.&lt;BR /&gt;I am using big data (more than 300 million).&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Sun, 20 Aug 2017 23:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389424#M66042</guid>
      <dc:creator>aminkarimid</dc:creator>
      <dc:date>2017-08-20T23:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389426#M66044</link>
      <description>&lt;P&gt;Because you also said:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;And I need a list of deleted observation from dataset.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2017 23:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389426#M66044</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-20T23:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389427#M66045</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138303"&gt;@aminkarimid&lt;/a&gt;, to remove an observation from a dataset, you either define which observation to delete or&lt;/P&gt;
&lt;P&gt;define which to output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can use either&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
 set have;
      if index(variable,'4') &amp;gt; 0 then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set have;
      in index(variable,'4') = 0 then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will get same results in both cases.&lt;/P&gt;
&lt;P&gt;You can use other functions than INDEX, like FIND - as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;mentiond.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2017 23:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389427#M66045</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-20T23:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389428#M66046</link>
      <description>&lt;P&gt;You can also split your data into two datasets:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data ok nok;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if index(variable,'4') then output nok;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else output ok;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2017 23:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389428#M66046</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-20T23:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the observation which has specific character and then remove it?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389440#M66048</link>
      <description>&lt;P&gt;I believe you already got some responses, just to add to those&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want to remove the data please try the perl regular expression functions which are an alternative to the regular search functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name_variable $20.;
if prxmatch('m/4$/i',strip(Name_variable))=0;
cards;
asdf1
asdg2
zxcv4
asdh3
qwer2
rtyu4
xcvb4
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Aug 2017 02:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-the-observation-which-has-specific-character-and/m-p/389440#M66048</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-08-21T02:07:28Z</dc:date>
    </item>
  </channel>
</rss>

