<?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: Find out history status of particular column using BASE SAS Programming in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486546#M126613</link>
    <description>&lt;P&gt;please try the below code, if you need further modification, check the if then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Number Status$         Date :ddmmyy10.;
status=propcase(status);
format date date9.;
cards; 
101        active        06/08/2018
101        Inactive     07/08/2018
101        inactive     08/08/2018
102        inactive     05/08/2018
102        active        06/08/2018
102        Inactive     07/08/2018
102        inactive     08/08/2018
;

proc sort data=have;
by number status;
run;

data want;
set have;
by number status;
retain new;
if first.status then new=date;
if status eq 'Inactive' then daysdiff=date-new;
format new date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Aug 2018 06:19:37 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2018-08-14T06:19:37Z</dc:date>
    <item>
      <title>Find out history status of particular column using BASE SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486543#M126610</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stucked at one task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BELOW IS THE SAMPLE DATA-SET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Number Status&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; active&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 06/08/2018&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Inactive&amp;nbsp; &amp;nbsp; &amp;nbsp;07/08/2018&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inactive&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;08/08/2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inactive&amp;nbsp; &amp;nbsp; &amp;nbsp;05/08/2018&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; active&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;06/08/2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Inactive&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;07/08/2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inactive&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;08/08/2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose today is 08/08/2018 and&amp;nbsp;&lt;STRONG&gt;Today's status is "Inactive"&lt;/STRONG&gt;&amp;nbsp;then I need to find out &lt;STRONG&gt;&amp;nbsp;how many days the status is "Inactive" for same number&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;I tried in multiple ways like giving flag, using LAG function but i dint crack the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest any path so that I can go through that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 05:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486543#M126610</guid>
      <dc:creator>india2016</dc:creator>
      <dc:date>2018-08-14T05:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find out history status of particular column using BASE SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486545#M126612</link>
      <description>Try to use RETAIN to keep the last active date within a Number BY group.</description>
      <pubDate>Tue, 14 Aug 2018 06:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486545#M126612</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-08-14T06:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find out history status of particular column using BASE SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486546#M126613</link>
      <description>&lt;P&gt;please try the below code, if you need further modification, check the if then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Number Status$         Date :ddmmyy10.;
status=propcase(status);
format date date9.;
cards; 
101        active        06/08/2018
101        Inactive     07/08/2018
101        inactive     08/08/2018
102        inactive     05/08/2018
102        active        06/08/2018
102        Inactive     07/08/2018
102        inactive     08/08/2018
;

proc sort data=have;
by number status;
run;

data want;
set have;
by number status;
retain new;
if first.status then new=date;
if status eq 'Inactive' then daysdiff=date-new;
format new date9.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 06:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486546#M126613</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-14T06:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Find out history status of particular column using BASE SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486550#M126616</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/123179"&gt;@india2016&lt;/a&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (where = (name = "Inactive"));
set have;
by id name;
if first.name then start = date;
retain start;
if last.name  then do;
	end = date;
	duration = end - start + 1;
	output;
	end;
format start end date10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Manoj&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 06:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486550#M126616</guid>
      <dc:creator>s_manoj</dc:creator>
      <dc:date>2018-08-14T06:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Find out history status of particular column using BASE SAS Programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486559#M126623</link>
      <description>&lt;P&gt;Something like this may do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by number;
  if first.number then
    days_inactive=0;
  if upcase(status)='ACTIVE' then
    days_inactive=0;
  else
    days_inactive+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 07:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-out-history-status-of-particular-column-using-BASE-SAS/m-p/486559#M126623</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-08-14T07:17:05Z</dc:date>
    </item>
  </channel>
</rss>

