<?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 How to specify conditions in an excel file and use them in the SAS code? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-specify-conditions-in-an-excel-file-and-use-them-in-the/m-p/713032#M219915</link>
    <description>&lt;P&gt;I want to filter a dataset based on a set of condition. The problem is the number of conditions is a lot and I was planning to have those conditions mentioned in an excel file like this:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&lt;BR /&gt;&lt;FONT color="#000000"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;BR /&gt;&lt;BR /&gt;And I want the conditions to be like:&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;data to_drop;
set previous_data;
where (ID = 1 and COUNT &amp;gt; 2 and TYPE = 'A')
        or (ID = 1 and COUNT &amp;gt; 3 and TYPE = 'B')
        or (ID = 2 and COUNT &amp;gt; 1 and TYPE = 'C');
run;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;But instead of manually adding all the hundreds of conditions to the code, I want them to be picked up from the excel.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jan 2021 11:27:42 GMT</pubDate>
    <dc:creator>vgoel</dc:creator>
    <dc:date>2021-01-21T11:27:42Z</dc:date>
    <item>
      <title>How to specify conditions in an excel file and use them in the SAS code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-specify-conditions-in-an-excel-file-and-use-them-in-the/m-p/713032#M219915</link>
      <description>&lt;P&gt;I want to filter a dataset based on a set of condition. The problem is the number of conditions is a lot and I was planning to have those conditions mentioned in an excel file like this:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; COUNT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TYPE&lt;BR /&gt;&lt;FONT color="#000000"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;C&lt;BR /&gt;&lt;BR /&gt;And I want the conditions to be like:&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;data to_drop;
set previous_data;
where (ID = 1 and COUNT &amp;gt; 2 and TYPE = 'A')
        or (ID = 1 and COUNT &amp;gt; 3 and TYPE = 'B')
        or (ID = 2 and COUNT &amp;gt; 1 and TYPE = 'C');
run;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#FF9900"&gt;&lt;FONT color="#000000"&gt;But instead of manually adding all the hundreds of conditions to the code, I want them to be picked up from the excel.&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jan 2021 11:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-specify-conditions-in-an-excel-file-and-use-them-in-the/m-p/713032#M219915</guid>
      <dc:creator>vgoel</dc:creator>
      <dc:date>2021-01-21T11:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify conditions in an excel file and use them in the SAS code?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-specify-conditions-in-an-excel-file-and-use-them-in-the/m-p/713034#M219916</link>
      <description>&lt;P&gt;First of all: do NOT use Excel for anything that is supposed to be a reliable solution. DON'T.&lt;/P&gt;
&lt;P&gt;Use a DATA step with DATALINES instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup;
input ID $ COUNT TYPE $;
datalines;
1 2 A
1 3 B
2 1 C
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, suppose you have a dataset like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ COUNT TYPE $;
datalines;
1 2 A
1 2 Z
1 3 B
1 3 Y
2 1 C
2 2 C
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you can use a &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lecompobjref&amp;amp;docsetTarget=n1eufww2rt03gcn1spj5siri07c9.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;hash object&lt;/A&gt; to do your subset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if _n_ = 1
then do;
  declare hash l (dataset:"lookup");
  l.definekey("ID","COUNT","TYPE");
  l.definedone();
end;
if l.check() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jan 2021 11:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-specify-conditions-in-an-excel-file-and-use-them-in-the/m-p/713034#M219916</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-21T11:37:10Z</dc:date>
    </item>
  </channel>
</rss>

