<?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: Where and If Statements with multiple options in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718042#M222136</link>
    <description>&lt;P&gt;Depends on exactly what you're doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case (and the next) you can chain your conditions together with an OR&lt;/P&gt;
&lt;PRE&gt;proc print data=lib.hf_d_patient_type;
where patient_type CONTAINS 'in_patient' 
          &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;or patient_type contains 'emergency_patient'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;;  
run;&lt;/PRE&gt;
&lt;P&gt;There's also an IN operator, if you're looking for exact matches, which is why this approach does not work for the first WHERE statement.&lt;/P&gt;
&lt;PRE&gt;data lib.dataB;

set mylib.dataA;

if patient_id &lt;FONT size="4" color="#FF6600"&gt;&lt;STRONG&gt;in (50, 105)&lt;/STRONG&gt;&lt;/FONT&gt; ;

run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368646"&gt;@Schtroumpfette&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I already have a lowcase table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also like to the add "emergency_patients" to "where" statement.&lt;/P&gt;
&lt;P&gt;/*Identify Patient_Type_ID for in_patients and emergency_patients*/&lt;/P&gt;
&lt;P&gt;title 'Proc Print&amp;nbsp; patientid for in)patients';&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; data=lib.hf_d_patient_type;&lt;/P&gt;
&lt;P&gt;where patient_type CONTAINS 'in_patient';&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add another patient_id,&amp;nbsp; "105" to the "if" statement.&lt;/P&gt;
&lt;P&gt;/*Restrict Encounters to Inpatients Aged 18 Years or Above*/&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data &lt;/STRONG&gt;lib.dataB;&lt;/P&gt;
&lt;P&gt;set mylib.dataA;&lt;/P&gt;
&lt;P&gt;if patient_id=50;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Schtroumfette!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2021 22:11:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-09T22:11:17Z</dc:date>
    <item>
      <title>Where and If Statements with multiple options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718038#M222134</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I already have a lowcase table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also like to the add "emergency_patients" to "where" statement.&lt;/P&gt;&lt;P&gt;/*Identify Patient_Type_ID for in_patients and emergency_patients*/&lt;/P&gt;&lt;P&gt;title 'Proc Print&amp;nbsp; patientid for in)patients';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; data=lib.hf_d_patient_type;&lt;/P&gt;&lt;P&gt;where patient_type CONTAINS 'in_patient';&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to add another patient_id,&amp;nbsp; "105" to the "if" statement.&lt;/P&gt;&lt;P&gt;/*Restrict Encounters to Inpatients Aged 18 Years or Above*/&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data &lt;/STRONG&gt;lib.dataB;&lt;/P&gt;&lt;P&gt;set mylib.dataA;&lt;/P&gt;&lt;P&gt;if patient_id=50;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Schtroumfette!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 21:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718038#M222134</guid>
      <dc:creator>Schtroumpfette</dc:creator>
      <dc:date>2021-02-09T21:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Where and If Statements with multiple options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718042#M222136</link>
      <description>&lt;P&gt;Depends on exactly what you're doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case (and the next) you can chain your conditions together with an OR&lt;/P&gt;
&lt;PRE&gt;proc print data=lib.hf_d_patient_type;
where patient_type CONTAINS 'in_patient' 
          &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;or patient_type contains 'emergency_patient'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;;  
run;&lt;/PRE&gt;
&lt;P&gt;There's also an IN operator, if you're looking for exact matches, which is why this approach does not work for the first WHERE statement.&lt;/P&gt;
&lt;PRE&gt;data lib.dataB;

set mylib.dataA;

if patient_id &lt;FONT size="4" color="#FF6600"&gt;&lt;STRONG&gt;in (50, 105)&lt;/STRONG&gt;&lt;/FONT&gt; ;

run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368646"&gt;@Schtroumpfette&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I already have a lowcase table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also like to the add "emergency_patients" to "where" statement.&lt;/P&gt;
&lt;P&gt;/*Identify Patient_Type_ID for in_patients and emergency_patients*/&lt;/P&gt;
&lt;P&gt;title 'Proc Print&amp;nbsp; patientid for in)patients';&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;print&lt;/STRONG&gt; data=lib.hf_d_patient_type;&lt;/P&gt;
&lt;P&gt;where patient_type CONTAINS 'in_patient';&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to add another patient_id,&amp;nbsp; "105" to the "if" statement.&lt;/P&gt;
&lt;P&gt;/*Restrict Encounters to Inpatients Aged 18 Years or Above*/&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data &lt;/STRONG&gt;lib.dataB;&lt;/P&gt;
&lt;P&gt;set mylib.dataA;&lt;/P&gt;
&lt;P&gt;if patient_id=50;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Schtroumfette!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718042#M222136</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-09T22:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Where and If Statements with multiple options</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718075#M222152</link>
      <description>Thank you Reeza,&lt;BR /&gt;&lt;BR /&gt;The if statement worked, thanks.&lt;BR /&gt;&lt;BR /&gt;The where statement did not work but that is fine. I run them separately and it worked and it was for a quality check.&lt;BR /&gt;&lt;BR /&gt;Very helpful,&lt;BR /&gt;Thank you again,&lt;BR /&gt;Nisrine</description>
      <pubDate>Wed, 10 Feb 2021 00:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-and-If-Statements-with-multiple-options/m-p/718075#M222152</guid>
      <dc:creator>Schtroumpfette</dc:creator>
      <dc:date>2021-02-10T00:11:12Z</dc:date>
    </item>
  </channel>
</rss>

