<?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: Date functions and logic in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57961#M16174</link>
    <description>proc sql;&lt;BR /&gt;
select&lt;BR /&gt;
  t1.id,&lt;BR /&gt;
  t1.login,&lt;BR /&gt;
  case when intnx('day',date(),-90) &amp;gt;= t2.lastlogin then 'Active' else 'Inactive' as Current_Status&lt;BR /&gt;
from work.logins t1 inner join (select id, max(login) as LastLogin from work.logins group by id) t2 on t1.id=t2.id;&lt;BR /&gt;
quit;</description>
    <pubDate>Wed, 27 Apr 2011 16:07:05 GMT</pubDate>
    <dc:creator>DBailey</dc:creator>
    <dc:date>2011-04-27T16:07:05Z</dc:date>
    <item>
      <title>Date functions and logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57960#M16173</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to determine an id's status based on if they have had any activity in the past 3 months.&lt;BR /&gt;
My data is a log of all activity and looks like:&lt;BR /&gt;
id LogIn&lt;BR /&gt;
1 01Jan11&lt;BR /&gt;
1 03Jan11 &lt;BR /&gt;
1 04Mar11&lt;BR /&gt;
2 27Jan11&lt;BR /&gt;
2 22Feb11&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
I want to be able to structure my data so it looks like the following:&lt;BR /&gt;
id LogIn Status&lt;BR /&gt;
1 01Jan11 Active&lt;BR /&gt;
1 03Jan11 Active&lt;BR /&gt;
1 04Mar11 Active&lt;BR /&gt;
2 25Dec10 Inactive&lt;BR /&gt;
2 27Jan11 Inactive&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
I think i need a function that checks whether or not the id has a Login date in the past 3 months, if yes, then status for id is set to Active.&lt;BR /&gt;
&lt;BR /&gt;
I'm pretty sure it has to be a separate dataset to do the calculations then do a Merge to the main file.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help!</description>
      <pubDate>Wed, 27 Apr 2011 15:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57960#M16173</guid>
      <dc:creator>KDang</dc:creator>
      <dc:date>2011-04-27T15:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date functions and logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57961#M16174</link>
      <description>proc sql;&lt;BR /&gt;
select&lt;BR /&gt;
  t1.id,&lt;BR /&gt;
  t1.login,&lt;BR /&gt;
  case when intnx('day',date(),-90) &amp;gt;= t2.lastlogin then 'Active' else 'Inactive' as Current_Status&lt;BR /&gt;
from work.logins t1 inner join (select id, max(login) as LastLogin from work.logins group by id) t2 on t1.id=t2.id;&lt;BR /&gt;
quit;</description>
      <pubDate>Wed, 27 Apr 2011 16:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57961#M16174</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2011-04-27T16:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date functions and logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57962#M16175</link>
      <description>You can use Hash Table.&lt;BR /&gt;
But I do not understand &lt;BR /&gt;
&lt;BR /&gt;
2 25Dec10 &lt;B&gt;Inactive&lt;/B&gt;&lt;BR /&gt;
2 27Jan11&lt;B&gt; Inactive&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Why they are inactive. dec10 is also included in past 3 month for jan11?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 28 Apr 2011 05:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57962#M16175</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-28T05:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date functions and logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57963#M16176</link>
      <description>Thanks for the replies.&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to make DBaily's statements work, but havent gotten it to work yet.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp, &lt;BR /&gt;
I'm practically trying to figure out how long since todays date was their last Login, so if its been longer than 90 days than their status would be inactive across all rows with that persons id.</description>
      <pubDate>Thu, 28 Apr 2011 13:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57963#M16176</guid>
      <dc:creator>KDang</dc:creator>
      <dc:date>2011-04-28T13:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Date functions and logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57964#M16177</link>
      <description>Ok I think i've figured it out.&lt;BR /&gt;
&lt;BR /&gt;
Essentially what I used was &lt;BR /&gt;
INTCK('day',Login,Today()) &lt;BR /&gt;
function to get the diff between the two dates then if value is less than 90 i set to Active, else Inactive.</description>
      <pubDate>Thu, 28 Apr 2011 14:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Date-functions-and-logic/m-p/57964#M16177</guid>
      <dc:creator>KDang</dc:creator>
      <dc:date>2011-04-28T14:10:39Z</dc:date>
    </item>
  </channel>
</rss>

