<?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 Result of when clause 2 is not the same data type in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524587#M4796</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing a when clause saying:&lt;/P&gt;&lt;P&gt;case when put(AB,1.)='1' then XY='0' else XY end as XY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AB is numeric and so to put it in the case statement I converted it to char but it is still saying the error "Result of when clause 2 is not the same data type as the preceding results".&lt;/P&gt;&lt;P&gt;XY is character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I put the case statement here !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance:)&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jan 2019 16:01:24 GMT</pubDate>
    <dc:creator>new_sas_user_4</dc:creator>
    <dc:date>2019-01-04T16:01:24Z</dc:date>
    <item>
      <title>Result of when clause 2 is not the same data type</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524587#M4796</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing a when clause saying:&lt;/P&gt;&lt;P&gt;case when put(AB,1.)='1' then XY='0' else XY end as XY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AB is numeric and so to put it in the case statement I converted it to char but it is still saying the error "Result of when clause 2 is not the same data type as the preceding results".&lt;/P&gt;&lt;P&gt;XY is character.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I put the case statement here !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance:)&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 16:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524587#M4796</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2019-01-04T16:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Result of when clause 2 is not the same data type</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524588#M4797</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am writing a when clause saying:&lt;/P&gt;
&lt;P&gt;case when put(AB,1.)='1' then XY='0' else XY end as XY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AB is numeric and so to put it in the case statement I converted it to char but it is still saying the error "Result of when clause 2 is not the same data type as the preceding results".&lt;/P&gt;
&lt;P&gt;XY is character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I put the case statement here !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The expression XY='0' is a Boolean expression, it evaluates as either true or false which in SAS is a&amp;nbsp;&lt;EM&gt;numeric&lt;/EM&gt;&amp;nbsp;one or zero. So you can't have a numeric in one case (&lt;SPAN&gt;when put(AB,1.)='1' then XY='0') and a character XY in the other case.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when AB=1 then '0' else XY end as XY&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 16:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524588#M4797</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-01-04T16:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Result of when clause 2 is not the same data type</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524599#M4799</link>
      <description>&lt;P&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 16:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Result-of-when-clause-2-is-not-the-same-data-type/m-p/524599#M4799</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2019-01-04T16:23:56Z</dc:date>
    </item>
  </channel>
</rss>

