<?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: How to detect an event on SAS and how to remove the observations that follow that event in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/379007#M3113</link>
    <description>&lt;P&gt;Would this solve your task?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by customer_id_ano churn notsorted;
if churn = 0 or first.churn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Jul 2017 13:59:46 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-07-25T13:59:46Z</dc:date>
    <item>
      <title>How to detect an event on SAS and how to remove the observations that follow that event</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/378980#M3111</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am using SAS University Edition v.9.4. and I am working on a dataset that detect when a customer is about to churn from a bank.&lt;BR /&gt;&lt;BR /&gt;Now, I need the following task to be performed by SAS and hoefully you can help. But first, let me provide you with a small datastep of my sample:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input customer_id_ano year month churn;
cards;
1 2017 1 0
1 2017 2 0
1 2017 3 0
1 2017 4 0
1 2017 5 0
1 2017 6 0
1 2017 7 0
1 2017 8 0
1 2017 9 1
1 2017 10 1
1 2017 11 1
1 2017 12 1
2 2017 1 0
2 2017 2 0
2 2017 3 0
2 2017 4 1
2 2017 5 1
2 2017 6 1
2 2017 7 1
2 2017 8 1
2 2017 9 1
2 2017 10 1
2 2017 11 1
2 2017 12 1
3 2017 1 1
3 2017 2 1
3 2017 3 1
3 2017 4 1
3 2017 5 1
3 2017 6 1
3 2017 7 1
3 2017 8 1
3 2017 9 1
3 2017 10 1
3 2017 11 1
3 2017 12 1
4 2017 1 0
4 2017 2 0
4 2017 3 0
4 2017 4 1
4 2017 5 1
4 2017 6 1
4 2017 7 1
4 2017 8 1
4 2017 9 1
4 2017 10 1
4 2017 11 1
4 2017 12 1
5 2017 1 0
5 2017 2 1
5 2017 3 1
5 2017 4 1
5 2017 5 1
5 2017 6 1
5 2017 7 1
5 2017 8 1
5 2017 9 1
5 2017 10 1
5 2017 11 1
5 2017 12 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now, what I need is SAS to detect when the variable churn is 1 for the first time and delete all the observations following that event. In other words, instead of a list of 1s following the first churn event, I only need to keep the first 1 and delete the remaining ones.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Let´s take customer_id_ano 1 as an example. We can see from the data step above that the variable churn for this customer is 1 starting from September 2017 and it remains 1 until the end of the observation period. Well, I only want the first churn=1 that occurred in September to remain in my dataset and the following observation must be dropped from it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope I managed to explai myself. And I would like to thank you in advance for the help you always provide to all the SAS beginners like me. Very appreciated!!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 13:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/378980#M3111</guid>
      <dc:creator>noemi_b</dc:creator>
      <dc:date>2017-07-25T13:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to detect an event on SAS and how to remove the observations that follow that event</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/379007#M3113</link>
      <description>&lt;P&gt;Would this solve your task?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by customer_id_ano churn notsorted;
if churn = 0 or first.churn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2017 13:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/379007#M3113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-25T13:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to detect an event on SAS and how to remove the observations that follow that event</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/379019#M3114</link>
      <description>&lt;P&gt;thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;! I will acknowledge you in my thesis &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 14:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-detect-an-event-on-SAS-and-how-to-remove-the-observations/m-p/379019#M3114</guid>
      <dc:creator>noemi_b</dc:creator>
      <dc:date>2017-07-25T14:19:12Z</dc:date>
    </item>
  </channel>
</rss>

