<?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: tekst naar nummer naar tekst in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753853#M29920</link>
    <description>&lt;P&gt;Hallo&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389309"&gt;@sieghild&lt;/a&gt;&amp;nbsp;en hartelijk welkom op het forum!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Switching to English now, sorry! :-)] Normally you shouldn't get this error message with your code as posted because the "result of WHEN clause 2" -- &lt;FONT face="courier new,courier"&gt;'minstens 1 maand'&lt;/FONT&gt; -- is a character value as is the "preceding result" --&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;'onbepaalde duur'&lt;/FONT&gt;. You would get the error message if you replaced &lt;EM&gt;one&lt;/EM&gt; of the two character strings with a numeric value, e.g., 1. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is an example where an exact copy of your code works as expected:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input id end_date :$8. total_days;
cards;
1 20211231 50000
2 20210713 40000
3 20211011 20000
;

proc sql;
select
&lt;STRONG&gt;case
when p.end_date = '20211231' then 'onbepaalde duur'
when p.total_days/1000 &amp;gt; 30 then 'minstens 1 maand'
else ''
end as ziektetermijn,&lt;/STRONG&gt;
id
from have p;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389309"&gt;@sieghild&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;p.end_date is een char van 6&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.total_days is ook een char van 6&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you saying that these are character variables of length 6? That would be a problem because &lt;FONT face="courier new,courier"&gt;p.end_date&lt;/FONT&gt; could never be equal to an &lt;EM&gt;8&lt;/EM&gt;-character string such as &lt;FONT face="courier new,courier"&gt;'20211231'&lt;/FONT&gt; and attempting to divide&amp;nbsp;&lt;FONT face="courier new,courier"&gt;p.total_days&lt;/FONT&gt; by 1000 would cause an &lt;FONT face="courier new,courier"&gt;ERROR: Expression using division (/) requires numeric types.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid all these type conflicts, you just need to know the types (and possible values) of your variables and handle them accordingly when coding comparisons, calculations or value assignments.&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 18:23:52 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-07-13T18:23:52Z</dc:date>
    <item>
      <title>tekst naar nummer naar tekst</title>
      <link>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753771#M29910</link>
      <description>&lt;P&gt;Ik krijg altijd de melding "ERROR: Result of WHEN clause 2 is not the same data type as the preceding results"&lt;/P&gt;&lt;P&gt;p.end_date is een char van 6&amp;nbsp;&lt;/P&gt;&lt;P&gt;p.total_days is ook een char van 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;case&lt;BR /&gt;when p.end_date = '20211231' then 'onbepaalde duur'&lt;BR /&gt;when p.total_days/1000 &amp;gt; 30 then 'minstens 1 maand'&lt;BR /&gt;else ''&lt;/P&gt;&lt;P&gt;end as ziektetermijn,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hoe kan ik dit oplossen?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753771#M29910</guid>
      <dc:creator>sieghild</dc:creator>
      <dc:date>2021-07-13T13:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: tekst naar nummer naar tekst</title>
      <link>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753852#M29919</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure about how your original data set is structured like, but you may be after something like the below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
LENGTH end_date $ 8 total_days $ 6;
end_date='20211231'; total_days='';      output;
end_date=''        ; total_days='40000'; output;
run;

PROC SQL noprint;
 create table want as
 select *
, case
when p.end_date = '20211231'           then 'onbepaalde duur'
when input(p.total_days,6.)/1000 &amp;gt; 30  then 'minstens 1 maand'
else ''
end as ziektetermijn
 from have as p;
QUIT;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753852#M29919</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-07-13T18:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: tekst naar nummer naar tekst</title>
      <link>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753853#M29920</link>
      <description>&lt;P&gt;Hallo&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389309"&gt;@sieghild&lt;/a&gt;&amp;nbsp;en hartelijk welkom op het forum!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[Switching to English now, sorry! :-)] Normally you shouldn't get this error message with your code as posted because the "result of WHEN clause 2" -- &lt;FONT face="courier new,courier"&gt;'minstens 1 maand'&lt;/FONT&gt; -- is a character value as is the "preceding result" --&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;'onbepaalde duur'&lt;/FONT&gt;. You would get the error message if you replaced &lt;EM&gt;one&lt;/EM&gt; of the two character strings with a numeric value, e.g., 1. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is an example where an exact copy of your code works as expected:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input id end_date :$8. total_days;
cards;
1 20211231 50000
2 20210713 40000
3 20211011 20000
;

proc sql;
select
&lt;STRONG&gt;case
when p.end_date = '20211231' then 'onbepaalde duur'
when p.total_days/1000 &amp;gt; 30 then 'minstens 1 maand'
else ''
end as ziektetermijn,&lt;/STRONG&gt;
id
from have p;
quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389309"&gt;@sieghild&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;p.end_date is een char van 6&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.total_days is ook een char van 6&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you saying that these are character variables of length 6? That would be a problem because &lt;FONT face="courier new,courier"&gt;p.end_date&lt;/FONT&gt; could never be equal to an &lt;EM&gt;8&lt;/EM&gt;-character string such as &lt;FONT face="courier new,courier"&gt;'20211231'&lt;/FONT&gt; and attempting to divide&amp;nbsp;&lt;FONT face="courier new,courier"&gt;p.total_days&lt;/FONT&gt; by 1000 would cause an &lt;FONT face="courier new,courier"&gt;ERROR: Expression using division (/) requires numeric types.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid all these type conflicts, you just need to know the types (and possible values) of your variables and handle them accordingly when coding comparisons, calculations or value assignments.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753853#M29920</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-13T18:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: tekst naar nummer naar tekst</title>
      <link>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753854#M29921</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;See also my previous post!!&lt;/P&gt;
&lt;P&gt;Your "end_date" needs to be char 8 instead of char 6.&lt;/P&gt;
&lt;P&gt;Not such a good practice to work with dates stored in character variables. Make your date a real (SAS) date!&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/tekst-naar-nummer-naar-tekst/m-p/753854#M29921</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-07-13T18:24:09Z</dc:date>
    </item>
  </channel>
</rss>

