<?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 retain a value from the previous row to do calculations on current row? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371069#M88641</link>
    <description>&lt;P&gt;You will get more responses if you post your new question as a new question .. not a continuation of the previous question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jun 2017 22:04:46 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-06-27T22:04:46Z</dc:date>
    <item>
      <title>How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370765#M88549</link>
      <description>&lt;P&gt;Hello SAS world,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need your help with the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;P&gt;&lt;U&gt;PatientID&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;Date&lt;/U&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/22/2012&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/30/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/02/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Want:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;PatientID&lt;/U&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;Date&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;U&gt;Diff&lt;/U&gt;&lt;/P&gt;&lt;P&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/22/2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/30/2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;01/31/2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;02/02/2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 21:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370765#M88549</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-26T21:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370768#M88550</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  by PatientID;
  diff=ifn(first.PatientID eq 0,dif(date),0);
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 22:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370768#M88550</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-26T22:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370780#M88551</link>
      <description>&lt;P&gt;another way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option missing=0;
data have;
input PatientID $          Date :mmddyy10.;
lagdate=intck('day',lag(date),date);
format date date9.;
cards;
X                      01/22/2012
X                      01/30/2012
X                      01/31/2012
X                      02/02/2012
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Jun 2017 00:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370780#M88551</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-27T00:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370832#M88556</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need a line to reset the calculated difference to zero for the first obs in an ID group. Something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;option missing=0;&lt;BR /&gt;data have;&lt;BR /&gt;input PatientID $ Date :mmddyy10.;&lt;BR /&gt;lagdate=intck('day',lag(date),date);&lt;BR /&gt;if PatientID ne lag(PatientID) then lagdate = 0;&lt;BR /&gt;format date date9.;&lt;BR /&gt;cards;&lt;BR /&gt;X 01/22/2012&lt;BR /&gt;X 01/30/2012&lt;BR /&gt;X 01/31/2012&lt;BR /&gt;X 02/02/2012&lt;BR /&gt;y 01/22/2017&lt;BR /&gt;y 01/30/2017&lt;BR /&gt;y 01/31/2017&lt;BR /&gt;y 02/02/2017&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 07:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370832#M88556</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2017-06-27T07:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370837#M88557</link>
      <description>I don't need the step of lagdate = 0; because in my code i used options missing=0; what this does is it assigns the value 0 to the missing values.</description>
      <pubDate>Tue, 27 Jun 2017 08:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370837#M88557</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-27T08:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370953#M88596</link>
      <description>Thank you!</description>
      <pubDate>Tue, 27 Jun 2017 14:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370953#M88596</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-27T14:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370954#M88597</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 14:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/370954#M88597</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-27T14:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371005#M88620</link>
      <description>&lt;P&gt;Hi ... OPTIONS MISSING=0 does NOT change values of missing data in a data set to ZERO. It only changes the way they appear when printed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1169&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1170 options missing=0;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1171 data x;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1172 x = 1;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1173 y = .;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1174 z = x + y;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;1175 run;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt; Each place is given by: (Number of times) at (Line) : (Column).&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt; 1 at 1174:7&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;If you print data set X you see ZEROES (due to the OPTIONS statement), but if you look at the LOG, you'll notice that SAS still sees MISSING data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;From online help (notice that it says printed)...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Syntax&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;MISSING=&amp;lt;'&amp;gt;character&amp;lt;'&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;Syntax Description&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;&amp;lt;'&amp;gt;character&amp;lt;'&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;specifies the value to be printed. The value can be any character. Single or double quotation marks are optional. The period is the default.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 17:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371005#M88620</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2017-06-27T17:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371062#M88640</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9903i5EB3BD582B91882E/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the earlier help, I need your help to solve the next problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the previous output I got the difference between dates. In the study period, I want to flag patients where there is difference of &amp;gt;120 days and mark all the dates after that &amp;gt;120 days. If there is a patients who have 2 rows of &amp;gt;120 days then I want to mark first &amp;gt;120 days to the 2nd &amp;gt;120 days as "R1" and "R2" for dates greater than 2nd &amp;gt;120 days.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 21:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371062#M88640</guid>
      <dc:creator>Sujithpeta</dc:creator>
      <dc:date>2017-06-27T21:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain a value from the previous row to do calculations on current row?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371069#M88641</link>
      <description>&lt;P&gt;You will get more responses if you post your new question as a new question .. not a continuation of the previous question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 22:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-a-value-from-the-previous-row-to-do-calculations/m-p/371069#M88641</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-27T22:04:46Z</dc:date>
    </item>
  </channel>
</rss>

