<?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: Case statement multiple conditions in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752477#M29778</link>
    <description>&lt;P&gt;Please be a little more specific in presenting the code that works fine, the code that caused the trouble, and what the problem is.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jul 2021 01:28:03 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-07-07T01:28:03Z</dc:date>
    <item>
      <title>Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752470#M29777</link>
      <description>&lt;P&gt;I ran the below to create a computed column and everything worked fine. I then tried to edit this same code in working with data in different data set requiring multiple conditions to be met - meaning when x =1 and y = 1 and z = 1 and aa = 1, then the computed column "Work" but having trouble. How to I use AND for multiple conditions on different data columns?&amp;nbsp; I'm working in SAS EG 7.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case when XXX_ALL_DIM.lif_IND = 1 then 'Yes'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when YYY_ALL_DIM.lif_IND = 2 then 'No'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when ZZZ_ALL_DIM.lif_IND = 3 then 'Maybe'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 'Other'&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 00:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752470#M29777</guid>
      <dc:creator>MichaelC02</dc:creator>
      <dc:date>2021-07-07T00:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752477#M29778</link>
      <description>&lt;P&gt;Please be a little more specific in presenting the code that works fine, the code that caused the trouble, and what the problem is.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 01:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752477#M29778</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-07-07T01:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752478#M29779</link>
      <description>&lt;P&gt;A good starting point would be to explicitly store the results of your CASE expression in a column:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when XXX_ALL_DIM.lif_IND = 1 then 'Yes'
         when YYY_ALL_DIM.lif_IND = 2 then 'No'
         when ZZZ_ALL_DIM.lif_IND = 3 then 'Maybe'
         else 'Other'
end as MyCategory&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 01:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752478#M29779</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-07T01:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752481#M29780</link>
      <description>&lt;P&gt;This is the code I created for a new column and it worked just fine - but it's more of an If/Then. I'm now working with a different data set and I want to again create a new column that looks at 4 other columns from the data I'm querying and if each, all four of the columns,&amp;nbsp; meets the criteria I have then I want the new column to reflect YES. Even if only one of the columns does does meet the criteria then Other, which would be NO.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case when BRWR_ALL_DIM.WIM_IND = 1 then 'PWM'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when BRWR_ALL_DIM.WIM_IND = 2 then 'WFA'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when BRWR_ALL_DIM.WIM_IND = 3 then 'WFA &amp;amp; PWM'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else 'Other'&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 02:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752481#M29780</guid>
      <dc:creator>MichaelC02</dc:creator>
      <dc:date>2021-07-07T02:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752490#M29781</link>
      <description>&lt;P&gt;Yes, the query will work fine, but if you are creating a table and want the column created from the CASE expression to not have a default name then you need to specify what you actually want to call it as in my example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding using CASE with four input columns - yes that is perfectly feasible. Please post what you have tried so far as the example you have posted doesn't appear to be related to your question.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 04:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752490#M29781</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-07T04:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752496#M29782</link>
      <description>&lt;P&gt;Looks like a perfect task for a format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fomat;
  value YesNoMaybe
    1 = 'Yes'
    2 = 'No'
    3 = 'Maybe'
    other = 'other'
  ;
run;

proc print data=have;
  format lif_IND YesNoMaybe.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jul 2021 06:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752496#M29782</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-07T06:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Case statement multiple conditions</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752499#M29783</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when x = 1 and y = 1 and z = 1 then 1
  else 0
end as a&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use compound conditions in SQL like anywhere else.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 07:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Case-statement-multiple-conditions/m-p/752499#M29783</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-07T07:22:13Z</dc:date>
    </item>
  </channel>
</rss>

