<?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: how to switch between data types in Case statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454094#M114777</link>
    <description>&lt;P&gt;Correct, you cannot mix chars into numerical variables.&lt;/P&gt;
&lt;P&gt;You have some options. Either store the result in a char variable (requires put() on the t1.variable).&lt;/P&gt;
&lt;P&gt;Or perhaps can live with using 0 or . (Missing) instead of a NO. (Which a format could fix).&lt;/P&gt;</description>
    <pubDate>Sat, 14 Apr 2018 00:43:24 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2018-04-14T00:43:24Z</dc:date>
    <item>
      <title>how to switch between data types in Case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454090#M114775</link>
      <description>&lt;P&gt;I have a sample proc sql code that wont run.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select
	(CASE 
		WHEN t1.variable = 0 THEN 'No'
		ELSE t1.variable end) as ColumnName
FROM TABLE T1;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Running this gives me an error of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"Result of WHEN Clause 2 is not the same data type as the preceding results"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it because the result wants to be an integer?&amp;nbsp; If so, how do I out put a "NO"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to put a colon between the 0, but get the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Expressing using equals (=) has components of different data types
result of when clause 2 is not the same data type as preceding results&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Apr 2018 00:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454090#M114775</guid>
      <dc:creator>mrdlau</dc:creator>
      <dc:date>2018-04-14T00:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to switch between data types in Case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454094#M114777</link>
      <description>&lt;P&gt;Correct, you cannot mix chars into numerical variables.&lt;/P&gt;
&lt;P&gt;You have some options. Either store the result in a char variable (requires put() on the t1.variable).&lt;/P&gt;
&lt;P&gt;Or perhaps can live with using 0 or . (Missing) instead of a NO. (Which a format could fix).&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 00:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454094#M114777</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-04-14T00:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to switch between data types in Case statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454111#M114780</link>
      <description>&lt;P&gt;If you require "No" for display purposes then a format would do a good job:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value no
0 = "No";
run;

proc sql;
select
    t1.variable as ColumnName format = no.
FROM T1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Apr 2018 04:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-switch-between-data-types-in-Case-statement/m-p/454111#M114780</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-04-14T04:36:21Z</dc:date>
    </item>
  </channel>
</rss>

