<?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: Searching within a variable in a dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126203#M34671</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@anca thanks for that, I will try it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please explain&amp;nbsp; this part? - &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;m/test/oi&lt;/SPAN&gt; - what does the m and the oi do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Jan 2013 19:06:45 GMT</pubDate>
    <dc:creator>vomer</dc:creator>
    <dc:date>2013-01-15T19:06:45Z</dc:date>
    <item>
      <title>Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126199#M34667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering if this is possible - and if so how? :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset called test - it contains values like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COL1&amp;nbsp;&amp;nbsp;&amp;nbsp; COL2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; COL3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Test why&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OQSJ&lt;/P&gt;&lt;P&gt;AIW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is ex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; QSDJ&lt;/P&gt;&lt;P&gt;AIQ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why Test&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KAJL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Is there any way in sas to search COL2 for the word "Test" and then output a new dataset that only contains the rows that had the word "Test" somewhere in COL2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Is there any way in sas for me to search specific sentences in COL2? Example - I want sas to search for "This is ex" and "Why Test" and output a new dataset that only contains rows where these two are true.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please post sample code if possible. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 15:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126199#M34667</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2013-01-15T15:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126200#M34668</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 see below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*read in your data;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input col1 $1-4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col2 $ 5-14&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col3 $ 15-18;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;ABB Test why&amp;nbsp; OQSJ&lt;/P&gt;&lt;P&gt;AIW This is ex QSDJ&lt;/P&gt;&lt;P&gt;AIQ Why Test&amp;nbsp; KAJL&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;*only keep the records that have in COL2 the word "test";&lt;/P&gt;&lt;P&gt;data want_1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test (where= (prxmatch("m/test/oi",col2) &amp;gt; 0));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*only keep the records that have "why test' or "this is ex";&lt;/P&gt;&lt;P&gt;data want_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test (where= (prxmatch("m/Why test|this is ex/oi",col2) &amp;gt; 0));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also run the data once;&lt;/P&gt;&lt;P&gt;data want_1 want_2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (prxmatch("m/test/oi",col2) &amp;gt; 0)) then output want_1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (prxmatch("m/Why test|this is ex/oi",col2) &amp;gt; 0)) then output want_2; the two data &lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I collapsed the two data steps into one.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 15:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126200#M34668</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-01-15T15:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126201#M34669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can also look up the FIND and INDEX function in SAS. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 15:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126201#M34669</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-15T15:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126202#M34670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql; create table one as (select col1,col2,col3 from hello where col2 like '%Test%' ); create table two as (select col1,col2,col3 from hello where ((col2&amp;nbsp; like 'This is ex%') or (col2 like 'Why Test%')) ); run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 15:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126202#M34670</guid>
      <dc:creator>NagendraKumarK</dc:creator>
      <dc:date>2013-01-15T15:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126203#M34671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@anca thanks for that, I will try it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please explain&amp;nbsp; this part? - &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;m/test/oi&lt;/SPAN&gt; - what does the m and the oi do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 19:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126203#M34671</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2013-01-15T19:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126204#M34672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vomer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&lt;STRONG&gt; 'm' tag&lt;/STRONG&gt; at the beginning of the search string tells PRXMATCH that it is doing a matching operation, this is the default. &lt;STRONG&gt;So you could delete it.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The 'o' tag at the end tells SAS to compile the parse string once. This is also the default because the parse string is a constant.&lt;STRONG&gt; So you can take this one off, too.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The 'i' tag at the end forces a case insensitive match so that "THIS" is equal to "this" for the purpose of matching.&amp;nbsp; &lt;STRONG&gt;If you want case sensitive you use "-i"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;See more on PRXMATCH here:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/38/719.html" title="http://support.sas.com/kb/38/719.html"&gt;38719 - Use PRXMATCH in place of multiple INDEX functions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 19:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126204#M34672</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2013-01-15T19:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Searching within a variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126205#M34673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! that is really interesting. I will read up on it as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 20:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Searching-within-a-variable-in-a-dataset/m-p/126205#M34673</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2013-01-15T20:08:14Z</dc:date>
    </item>
  </channel>
</rss>

