<?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 Case When Expression and multiple data types in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302476#M60708</link>
    <description>&lt;P&gt;Hi All -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cannot get past "ERROR: Result of WHEN clause 2 is not the same data type as the preceding results." &amp;nbsp;Stumped with this sequence of events....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Prior PROC SQL step:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;..............&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input(A.INITIAL_DELV_D,yymmdd8.) as INIT_DELV_DT length=8 label="INIT_DELV_DT" format=DATE9. informat=DATE9.,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input(A.CURR_DELIVERY_D,yymmdd8.) as CURR_DELV_DT length=8 label="CURR_DELV_DT" format=DATE9. informat=DATE9.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.............. &amp;nbsp;&lt;/SPAN&gt;All looks good after this step......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current PROC SQL step:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Create Table REVENUE_EW As&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Select DISTINCT A.FISCAL_YEAR, A.FISCAL_MONTH, A.SERNO,&amp;nbsp;A.INIT_DELV_DT, A.CURR_DELV_DT, &amp;nbsp;A.AMOUNT,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE When B.ALT_EXP_DT IS NOT NULL Then B.ALT_EXP_DT Else B.EXPIRATION_DT End AS SECURE_EXP_DT "SECURE_EXP_DT" format=DATE9.,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE WHEN A.TYPE_ID = 1 THEN A.BASIC_ST_DT WHEN A.TYPE_ID = 2 THEN A.CURR_DELV_DT Else " " END AS SECURE_ST_DT "SECURE_ST_DT" format=Date9.,&lt;BR /&gt;CASE WHEN A.TYPE_ID = 1 THEN "NEW, TRANSFER, UPGRADE" WHEN A.TYPE_ID = 2 THEN "CERTIFIED USED" Else " " END AS TYPE "TYPE",&lt;BR /&gt;From REVENUE1 A;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After informating CURR_DELV_DT, it has the same length, format and informat as BASIC_ST_DT. &amp;nbsp;Not sure where the obvious issue is. &amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2016 21:49:28 GMT</pubDate>
    <dc:creator>Airintheballoon</dc:creator>
    <dc:date>2016-10-04T21:49:28Z</dc:date>
    <item>
      <title>Case When Expression and multiple data types</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302476#M60708</link>
      <description>&lt;P&gt;Hi All -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cannot get past "ERROR: Result of WHEN clause 2 is not the same data type as the preceding results." &amp;nbsp;Stumped with this sequence of events....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Prior PROC SQL step:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;..............&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input(A.INITIAL_DELV_D,yymmdd8.) as INIT_DELV_DT length=8 label="INIT_DELV_DT" format=DATE9. informat=DATE9.,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input(A.CURR_DELIVERY_D,yymmdd8.) as CURR_DELV_DT length=8 label="CURR_DELV_DT" format=DATE9. informat=DATE9.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;.............. &amp;nbsp;&lt;/SPAN&gt;All looks good after this step......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current PROC SQL step:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Create Table REVENUE_EW As&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Select DISTINCT A.FISCAL_YEAR, A.FISCAL_MONTH, A.SERNO,&amp;nbsp;A.INIT_DELV_DT, A.CURR_DELV_DT, &amp;nbsp;A.AMOUNT,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE When B.ALT_EXP_DT IS NOT NULL Then B.ALT_EXP_DT Else B.EXPIRATION_DT End AS SECURE_EXP_DT "SECURE_EXP_DT" format=DATE9.,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CASE WHEN A.TYPE_ID = 1 THEN A.BASIC_ST_DT WHEN A.TYPE_ID = 2 THEN A.CURR_DELV_DT Else " " END AS SECURE_ST_DT "SECURE_ST_DT" format=Date9.,&lt;BR /&gt;CASE WHEN A.TYPE_ID = 1 THEN "NEW, TRANSFER, UPGRADE" WHEN A.TYPE_ID = 2 THEN "CERTIFIED USED" Else " " END AS TYPE "TYPE",&lt;BR /&gt;From REVENUE1 A;&lt;BR /&gt;Quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After informating CURR_DELV_DT, it has the same length, format and informat as BASIC_ST_DT. &amp;nbsp;Not sure where the obvious issue is. &amp;nbsp;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 21:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302476#M60708</guid>
      <dc:creator>Airintheballoon</dc:creator>
      <dc:date>2016-10-04T21:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Case When Expression and multiple data types</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302478#M60710</link>
      <description>&lt;P&gt;If you format your code, and use a code block, the little i or paper icon 6/7 icon at top of the editor, the code wlll be readable. As is, it's hard to decipher.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In fact, you can usually find the difference and answer pretty quickly once it's readable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 22:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302478#M60710</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-04T22:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Case When Expression and multiple data types</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302480#M60711</link>
      <description>&lt;P&gt;Its the ELSE " " END that's the issue. Your variable is numeric and missing in SAS for numeric is .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it should be&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Else .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;END&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 22:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302480#M60711</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-10-04T22:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Case When Expression and multiple data types</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302490#M60712</link>
      <description>&lt;P&gt;I knew it was going to be obvious....&amp;nbsp; Thanks everyone!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2016 23:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Case-When-Expression-and-multiple-data-types/m-p/302490#M60712</guid>
      <dc:creator>Airintheballoon</dc:creator>
      <dc:date>2016-10-04T23:48:44Z</dc:date>
    </item>
  </channel>
</rss>

