<?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 jump over specific row under cumulative sum? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496317#M131226</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date : yymmdd10. surgery_YN;
format date yymmdd10.;
cards;
1 2002/01/28 0 0
1 2002/02/15 0 0
1 2002/04/06 1 0
1 2002/05/05 0 0
1 2002/06/07 0 1
1 2002/08/10 0 0
1 2003/01/12 0 0
2 2003/01/15 0 0
2 2003/02/10 1 0
2 2003/03/10 0 1
2 2003/04/08 0 0
;





data want;
set have;
by id date;
if first.id then do;f=0;count=0;end;
f+surgery_YN;
if f&amp;lt;1 then count+1;
if lag(surgery_YN)=1 and surgery_YN=0 then count=0;
drop f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Sep 2018 17:16:43 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-09-17T17:16:43Z</dc:date>
    <item>
      <title>how to jump over specific row under cumulative sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496305#M131214</link>
      <description>&lt;P&gt;hello. i made data set, counting patient's visiting number(except admission) before they got surgery.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;raw data is here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id date admission_YN surgery_YN&lt;/P&gt;&lt;P&gt;1 2002/01/28 0 0&lt;BR /&gt;1 2002/02/15 0 0&lt;BR /&gt;1 2002/04/06 &lt;STRONG&gt;1&lt;/STRONG&gt; 0&lt;/P&gt;&lt;P&gt;1 2002/05/05 0 0&lt;BR /&gt;1 2002/06/07 &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;1 2002/08/10 0 0&lt;BR /&gt;1 2003/01/12 0 0&lt;BR /&gt;2 2003/01/15&lt;SPAN&gt;&amp;nbsp;0&lt;/SPAN&gt;&amp;nbsp;0&lt;BR /&gt;2 2003/02/10&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;0&lt;BR /&gt;2 2003/03/10&amp;nbsp;&lt;SPAN&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;2 2003/04/08&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and with this code, i made a data set. but i can't exclude(=jump over) visiting for admission.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;BR /&gt;by id date;&lt;BR /&gt;run;&lt;BR /&gt;data want;&lt;BR /&gt;retain had_surgery;&lt;BR /&gt;set have;&lt;BR /&gt;by Id date;&lt;BR /&gt;if first.id then&lt;BR /&gt;do;&lt;BR /&gt;had_surgery = 0;&lt;BR /&gt;count = 0;&lt;BR /&gt;end;&lt;BR /&gt;if surgery_yn = 0 and had_surgery = 0 then count+1;&lt;BR /&gt;else if surgery_yn = 1 then&lt;BR /&gt;do;&lt;BR /&gt;had_surgery = 1;&lt;BR /&gt;count=0 ;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id date admission_YN surgery_YN count&lt;/P&gt;&lt;P&gt;1 2002/01/28 0 0 &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;1 2002/02/15 0 0 &lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;1 2002/04/06 &lt;STRONG&gt;1&lt;/STRONG&gt; 0 &lt;U&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1 2002/05/05 0 0 &lt;STRONG&gt;4&lt;/STRONG&gt;&lt;BR /&gt;1 2002/06/07 &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1 &lt;/STRONG&gt;0&lt;BR /&gt;1 2002/08/10 0 0 0&lt;BR /&gt;1 2003/01/12 0 0 0&lt;BR /&gt;2 2003/01/15&lt;SPAN&gt;&amp;nbsp;0&lt;/SPAN&gt;&amp;nbsp;0 &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;2 2003/02/10&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;0 &lt;U&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;2 2003/03/10&amp;nbsp;&lt;SPAN&gt; &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;1 &lt;/STRONG&gt;0&lt;BR /&gt;2 2003/04/08&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;0 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want make data set like this. how can i jump over admission event?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id date admission_YN surgery_YN count&lt;/P&gt;&lt;P&gt;1 2002/01/28 0 0&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;1 2002/02/15 0 0&amp;nbsp;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;BR /&gt;1 2002/04/06 &lt;STRONG&gt;1&lt;/STRONG&gt; 0&amp;nbsp;&lt;STRONG&gt;&lt;U&gt;2&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1 2002/05/05 0 0&amp;nbsp;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;BR /&gt;1 2002/06/07&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;0&lt;BR /&gt;1 2002/08/10 0 0 0&lt;BR /&gt;1 2003/01/12 0 0 0&lt;BR /&gt;2 2003/01/15&amp;nbsp;0&amp;nbsp;0&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;BR /&gt;2 2003/02/10&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;0&amp;nbsp;&lt;STRONG&gt;&lt;U&gt;1&lt;/U&gt;&lt;/STRONG&gt;&lt;BR /&gt;2 2003/03/10&amp;nbsp;&lt;STRONG&gt;1&lt;/STRONG&gt; &lt;STRONG&gt;1&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;0&lt;BR /&gt;2 2003/04/08&amp;nbsp;0&amp;nbsp;0 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 17:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496305#M131214</guid>
      <dc:creator>km0927</dc:creator>
      <dc:date>2018-09-17T17:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to jump over specific row under cumulative sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496309#M131218</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if surgery_yn = 0 and had_surgery = 0 and admission_yn=0 then count+1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2018 17:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496309#M131218</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-17T17:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to jump over specific row under cumulative sum?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496317#M131226</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id date : yymmdd10. surgery_YN;
format date yymmdd10.;
cards;
1 2002/01/28 0 0
1 2002/02/15 0 0
1 2002/04/06 1 0
1 2002/05/05 0 0
1 2002/06/07 0 1
1 2002/08/10 0 0
1 2003/01/12 0 0
2 2003/01/15 0 0
2 2003/02/10 1 0
2 2003/03/10 0 1
2 2003/04/08 0 0
;





data want;
set have;
by id date;
if first.id then do;f=0;count=0;end;
f+surgery_YN;
if f&amp;lt;1 then count+1;
if lag(surgery_YN)=1 and surgery_YN=0 then count=0;
drop f;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Sep 2018 17:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-jump-over-specific-row-under-cumulative-sum/m-p/496317#M131226</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-09-17T17:16:43Z</dc:date>
    </item>
  </channel>
</rss>

