<?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: proc sql - selecting records with values &amp;quot;like&amp;quot;/&amp;quot;contain&amp;quot; that in another ta in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341307#M272751</link>
    <description>&lt;P&gt;If you know which values you are interested in best would be to place them in a dataset, especially if there are very many or could be from another set and then do a join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;select b.*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; from listdata as a, all.all_lab_lookup as b&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where upcase (b.lab_test_accesion_no) contains listdata.value;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where the dataset listdata would have one variable named value with each record consisting of one value like 'ABC123'&amp;nbsp;or 'CNDJD2984'&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this will generate a note in the log about a query that can't be optimized. This is because this compares every record from each dataset with every record in the other dataset.&lt;/P&gt;
&lt;P&gt;Be aware that if your search values are subsets of another value such as &lt;SPAN&gt;DASD23 and ASDASD2323 you will get duplicate values from the all_lab_lookup data because both would match the criteria.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2017 19:22:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-15T19:22:19Z</dc:date>
    <item>
      <title>proc sql - selecting records with values "like"/"contain" that in another table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341288#M272750</link>
      <description>&lt;P&gt;Hello - I am currently using the following code to select specific records from a dataset where field "lab_test_accession_no" contain strings that I am specifying.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-------------&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table check1 as select *&lt;BR /&gt;from all.all_lab_lookup&lt;BR /&gt;where&lt;BR /&gt;upcase(lab_test_accession_no) contains 'ABC123' OR&lt;BR /&gt;upcase(lab_test_accession_no) contains 'CNDJD2984' OR&lt;BR /&gt;upcase(lab_test_accession_no) contains 'JDFDJF3445';&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;----------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is: is there a way, besides manually specifying 'ABC123', '&lt;SPAN&gt;'CNDJD2984', etc. within the "Where" section, that I can refer to a table (example of the table below) with a field containing those values? The reason I need an alternative to manual entry is that I am often searching for hundreds of these.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;accession_number&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ABC123&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CNDJD2984&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;JDFDJF3445&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ASDASD2323&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ASJHASJKDH32&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;---&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Importantly, I am not looking for only exact matches which I know I can use the "in" operator for, but, want to select the records where the accession_number is contained somewhere within my "lab_test_accession_no" field.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way? Thank you in advance for any insight.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 18:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341288#M272750</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2017-03-15T18:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql - selecting records with values "like"/"contain" that in another ta</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341307#M272751</link>
      <description>&lt;P&gt;If you know which values you are interested in best would be to place them in a dataset, especially if there are very many or could be from another set and then do a join.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;select b.*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; from listdata as a, all.all_lab_lookup as b&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where upcase (b.lab_test_accesion_no) contains listdata.value;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where the dataset listdata would have one variable named value with each record consisting of one value like 'ABC123'&amp;nbsp;or 'CNDJD2984'&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that this will generate a note in the log about a query that can't be optimized. This is because this compares every record from each dataset with every record in the other dataset.&lt;/P&gt;
&lt;P&gt;Be aware that if your search values are subsets of another value such as &lt;SPAN&gt;DASD23 and ASDASD2323 you will get duplicate values from the all_lab_lookup data because both would match the criteria.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 19:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341307#M272751</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-15T19:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql - selecting records with values "like"/"contain" that in another ta</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341320#M272752</link>
      <description>Thank you ballardw! It works great.</description>
      <pubDate>Wed, 15 Mar 2017 19:51:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-selecting-records-with-values-quot-like-quot-quot/m-p/341320#M272752</guid>
      <dc:creator>ucdcrush</dc:creator>
      <dc:date>2017-03-15T19:51:27Z</dc:date>
    </item>
  </channel>
</rss>

