<?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 Statement logic in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291114#M60302</link>
    <description>&lt;P&gt;Hi -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im trying to make a query that says, if the call happened within 7 days after the case creation then add a 1, otherwise 0 and if the call happened within 31 days after the case creation add a 1, otherwise 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the date is in the following format 01MAY2016 11:10:00 (datetime20) both case and call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is my formula currently but it didnt work correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test.rock as&lt;BR /&gt;select A.*,&lt;BR /&gt;(case when datepart( A.call)&amp;gt;datepart(a.case)+7 then 1 else 0 end) as call_in_7days,&lt;BR /&gt;(case when datepart( A.call)&amp;gt;datepart(a.case )+31 then 1 else 0 end) as call_in_31days&lt;BR /&gt;from test.paper A&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the results were incorrect. please advise if my logic is incorrect.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Aug 2016 01:28:48 GMT</pubDate>
    <dc:creator>itshere</dc:creator>
    <dc:date>2016-08-12T01:28:48Z</dc:date>
    <item>
      <title>Case Statement logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291114#M60302</link>
      <description>&lt;P&gt;Hi -&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im trying to make a query that says, if the call happened within 7 days after the case creation then add a 1, otherwise 0 and if the call happened within 31 days after the case creation add a 1, otherwise 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the date is in the following format 01MAY2016 11:10:00 (datetime20) both case and call.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is my formula currently but it didnt work correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test.rock as&lt;BR /&gt;select A.*,&lt;BR /&gt;(case when datepart( A.call)&amp;gt;datepart(a.case)+7 then 1 else 0 end) as call_in_7days,&lt;BR /&gt;(case when datepart( A.call)&amp;gt;datepart(a.case )+31 then 1 else 0 end) as call_in_31days&lt;BR /&gt;from test.paper A&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the results were incorrect. please advise if my logic is incorrect.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 01:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291114#M60302</guid>
      <dc:creator>itshere</dc:creator>
      <dc:date>2016-08-12T01:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291116#M60303</link>
      <description>&lt;P&gt;Look at cases where it didn't work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What were the values of Call and Case in those cases? Also, should your comparison be &amp;gt; or &amp;gt;=?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your logic is incorrect though.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the Call to be between Case and Case+7 , your checking if it's more than 7 days, which is a Call more than 7 days after a Case Creation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 01:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291116#M60303</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-12T01:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291119#M60304</link>
      <description>&lt;P&gt;I find&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table test.rock as&lt;BR /&gt;select A.*,&lt;BR /&gt;(case when datepart( A.call)-datepart(a.case)&amp;nbsp;&amp;gt; 7 then 1 else 0 end) as call_in_7days,&lt;BR /&gt;(case when datepart( A.call)-datepart(a.case ) &amp;gt; 31 then 1 else 0 end) as call_in_31days&lt;BR /&gt;from test.paper A&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;easier to read. And then you see your mistake. You probably mean&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create table test.rock as&lt;BR /&gt;select A.*,&lt;BR /&gt;(case when datepart( A.call) - datepart(a.case)&amp;nbsp;&amp;lt;= 7 then 1 else 0 end) as call_in_7days,&lt;BR /&gt;(case when datepart( A.call) - datepart(a.case ) &amp;lt;= 31 then 1 else 0 end) as call_in_31days&lt;BR /&gt;from test.paper A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which can also be written&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select A.*,&lt;BR /&gt;( datepart( A.call) - datepart(a.case)&amp;nbsp;&amp;lt;= 7 ) as call_in_7days,&lt;BR /&gt;( datepart( A.call) - datepart(a.case ) &amp;lt;= 31 ) as call_in_31days&lt;BR /&gt;from test.paper A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Aug 2016 01:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291119#M60304</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-08-12T01:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Case Statement logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291124#M60305</link>
      <description>&lt;P&gt;Simplify your code and make it independent of internal date and time representation. Use SAS date and time interval functions (&lt;STRONG&gt;intnx&lt;/STRONG&gt; and &lt;STRONG&gt;intck&lt;/STRONG&gt;). The "DTDAY" interval represents a day for datetime values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test.rock as
select 
	*,
	intck("DTDAY", case, call) &amp;lt;= 7  as call_in_7days,
	intck("DTDAY", case, call) &amp;lt;= 31  as call_in_31days
from test.paper;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Aug 2016 02:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Case-Statement-logic/m-p/291124#M60305</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-08-12T02:14:08Z</dc:date>
    </item>
  </channel>
</rss>

