<?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: Removing observations if case does not contain certain words in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305763#M8739</link>
    <description>&lt;P&gt;Great idea. However, use catx(" ", of _character_) instead of cats(),&amp;nbsp;and indexw() instead of index() to detect words.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2016 20:08:08 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-10-19T20:08:08Z</dc:date>
    <item>
      <title>Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305722#M8733</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a large dataset, many thousands of observations. However, only certain observations are relevant to me. If the data were not so messy, I would consider another way to approach what I want to do, but alas...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to delete cases that do not contain certain keywords on any of the variables. For example, the dataset contains events that have happened at public institutions. And I only want to keep the observations that mention "college" or "University" or "school" or "academy." The tricky thing is that I don't know where in the text strings of the certain variables that may reference these entities will show up. Sometimes the keyword "school" could show up on variable 5, sometimes the keyword "university" could show up on variable 3 and vice versa. Furthermore, these words are not the only words that will be in the text string of a variable. It will typically say something like &amp;nbsp;... happened at Y school. I only want to keep these sorts of observations and I want to delete others that mention other public institutions, e.g., state offices, etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully I've explained this adequately, your guidance is very much appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;R&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 17:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305722#M8733</guid>
      <dc:creator>r4321</dc:creator>
      <dc:date>2016-10-19T17:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305728#M8735</link>
      <description>&lt;P&gt;As long as you don't have a zillion variables, this should do it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;length test $ 32000;&lt;/P&gt;
&lt;P&gt;test = upcase(cats(of _character_));&lt;/P&gt;
&lt;P&gt;if index(test, 'UNIVERSITY')&lt;/P&gt;
&lt;P&gt;or index(test, 'SCHOOL')&lt;/P&gt;
&lt;P&gt;or index(test, 'COLLEGE')&lt;/P&gt;
&lt;P&gt;or index(test, 'ACADEMY');&lt;/P&gt;
&lt;P&gt;drop test;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The tricky part is that a length of 32,000 has to be long enough to hold all of your character variables put together.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 18:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305728#M8735</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-19T18:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305740#M8736</link>
      <description>&lt;P&gt;Here's a similar case, and some different approaches:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings14/1717-2014.pdf" target="_self"&gt;http://support.sas.com/resources/papers/proceedings14/1717-2014.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305740#M8736</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2016-10-19T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305763#M8739</link>
      <description>&lt;P&gt;Great idea. However, use catx(" ", of _character_) instead of cats(),&amp;nbsp;and indexw() instead of index() to detect words.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 20:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305763#M8739</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-10-19T20:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305895#M8745</link>
      <description>&lt;P&gt;Can you post your data and output here ?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 10:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/305895#M8745</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-20T10:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations if case does not contain certain words</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/306987#M8776</link>
      <description>Thank you.</description>
      <pubDate>Mon, 24 Oct 2016 23:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Removing-observations-if-case-does-not-contain-certain-words/m-p/306987#M8776</guid>
      <dc:creator>r4321</dc:creator>
      <dc:date>2016-10-24T23:27:49Z</dc:date>
    </item>
  </channel>
</rss>

