<?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: To find out the dates on which status changes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491149#M128738</link>
    <description>&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But need more help on this,&lt;/P&gt;&lt;P&gt;I am attaching the output that I an getting with your code(Namiing: HAVE).&lt;/P&gt;&lt;P&gt;Their ia a issue in that the red_date is not updating, it is showing the first date but I want red_date must be latest date on which status goes "OFF"&amp;nbsp;&lt;/P&gt;&lt;P&gt;for you help also attaching the output needed(Namming: WANT).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Aug 2018 09:38:28 GMT</pubDate>
    <dc:creator>kashish_joker</dc:creator>
    <dc:date>2018-08-30T09:38:28Z</dc:date>
    <item>
      <title>To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491137#M128729</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here i am having a data which contain a field status which varies with respect to date, what I want is find the dates on which its status get OFF and after getting OFF on which date if start working.&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input key System_Date $ status $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1-08-18 ON&lt;BR /&gt;1 2-08-18 OFF&lt;BR /&gt;1 3-08-18 OFF&lt;BR /&gt;1 4-08-18 OFF&lt;BR /&gt;1 5-08-18 OFF&lt;BR /&gt;2 1-08-18 ON&lt;BR /&gt;2 2-08-18 OFF&lt;BR /&gt;2 3-08-18 OFF&lt;BR /&gt;2 4-08-18 OFF&lt;BR /&gt;2 5-08-18 ON&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is how I want the output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;key System_Date $ status $ red_date $ green_date $&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;1-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ON&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;3-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;4-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;5-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; &amp;nbsp;2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;1-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;3-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;4-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;5-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ON&amp;nbsp; &amp;nbsp; 2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5-08-18&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 08:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491137#M128729</guid>
      <dc:creator>kashish_joker</dc:creator>
      <dc:date>2018-08-30T08:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491141#M128733</link>
      <description>&lt;P&gt;Use retain and if statements (going in meeting so will be breif):&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  length red_date green_date $20;
  retain red_date green_date;
  by key;
  if first.key then call missing(red_date,green_date);
  if status="OFF" and red_date="" then red_date=system_date;
  if status="ON" and red_date ne "" then green_date=system_date;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;Edit by KB: Added a "n" to "the" in the "if first." statement.&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 09:13:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491141#M128733</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-30T09:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491146#M128736</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221233"&gt;@kashish_joker&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here i am having a data which contain a field status which varies with respect to date, what I want is find the dates on which its status get OFF and after getting OFF on which date if start working.&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input key System_Date $ status $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1-08-18 ON&lt;BR /&gt;1 2-08-18 OFF&lt;BR /&gt;1 3-08-18 OFF&lt;BR /&gt;1 4-08-18 OFF&lt;BR /&gt;1 5-08-18 OFF&lt;BR /&gt;2 1-08-18 ON&lt;BR /&gt;2 2-08-18 OFF&lt;BR /&gt;2 3-08-18 OFF&lt;BR /&gt;2 4-08-18 OFF&lt;BR /&gt;2 5-08-18 ON&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is how I want the output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;key System_Date $ status $ red_date $ green_date $&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;1-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ON&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;3-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;4-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; 2-08-18&lt;BR /&gt;1&amp;nbsp; &amp;nbsp;5-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OFF&amp;nbsp; &amp;nbsp;2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;1-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ON&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;3-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;4-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OFF&amp;nbsp; 2-08-18&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;5-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ON&amp;nbsp; &amp;nbsp; 2-08-18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5-08-18&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in Advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Kudos for posting a very well composed question (example data, clear rule, expected output). Given the many other questions we see here that need a ping-pong of re-requests, this is exceptional for a first-time poster.&lt;/P&gt;
&lt;P&gt;There's room for only one little improvement: use the {i} or little running man icons for code (see my third footnote).&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 09:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491146#M128736</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-30T09:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491149#M128738</link>
      <description>&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But need more help on this,&lt;/P&gt;&lt;P&gt;I am attaching the output that I an getting with your code(Namiing: HAVE).&lt;/P&gt;&lt;P&gt;Their ia a issue in that the red_date is not updating, it is showing the first date but I want red_date must be latest date on which status goes "OFF"&amp;nbsp;&lt;/P&gt;&lt;P&gt;for you help also attaching the output needed(Namming: WANT).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 09:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491149#M128738</guid>
      <dc:creator>kashish_joker</dc:creator>
      <dc:date>2018-08-30T09:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491153#M128742</link>
      <description>&lt;P&gt;Sorry, I am not following the logic of your want.&amp;nbsp; Why does red-date go back to 1-08-18 at 04-8-18?&lt;/P&gt;
&lt;P&gt;Should just be a matter of changing the if statements yo what you want.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 10:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491153#M128742</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-30T10:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: To find out the dates on which status changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491160#M128746</link>
      <description>&lt;P&gt;Just a note of caution about your data ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Storing your SYSTEM_DATE as a character string will make life difficult down the road.&amp;nbsp; Unless your data ranges over a very limited set of dates, you won't be able to sort the data and put the observations in chronological order.&amp;nbsp; The problem occurs if the data ever crosses over more than one month.&amp;nbsp; SAS handles this by storing dates as numeric values, but you will need to study up on what SAS expects and how to get your data into that form.&amp;nbsp; If you must use character strings, use YMD order and the full set of digits possible, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2018-08-01 (assuming that represents August 1, 2018)&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 10:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-find-out-the-dates-on-which-status-changes/m-p/491160#M128746</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-30T10:49:39Z</dc:date>
    </item>
  </channel>
</rss>

