<?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: Running Total with Missing Values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241476#M308928</link>
    <description>Sort first and then calculate your running total?</description>
    <pubDate>Fri, 01 Jan 2016 20:17:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-01-01T20:17:13Z</dc:date>
    <item>
      <title>Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241434#M308915</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a data set that includes a running total.&amp;nbsp; In some observations, the value that is being added to the running total is missing.&amp;nbsp; Instead of keeping the previous running total, the new running total value for the record that is missing is also missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been researching all day.&amp;nbsp; I have tried the retain statement, just adding the running total to the next value (assuming that a missing value would act as Running Total=0) and nothing is working.&amp;nbsp; I couldn't get it to work with proc sql either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code and current results I am getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1337i97AAFA5B54121F71/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="SASCode.JPG" title="SASCode.JPG" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1338iFD7F4033FFFCB27C/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="RunningTotal.JPG" title="RunningTotal.JPG" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 21:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241434#M308915</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T21:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241437#M308916</link>
      <description>&lt;P&gt;Your code and the results&amp;nbsp;are&amp;nbsp;not matching. How the first retianed variable is bigger than the first not missing values???&lt;/P&gt;
&lt;P&gt;and many unnessesary statment is included like a=a;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The summing function and your code logic should handle the missing values?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 21:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241437#M308916</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-31T21:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241438#M308917</link>
      <description>Exactly my problem. I have no idea why they are not matching and why the summing function is not working. I tried that as well. I am hoping that someone can help me figure out what I am doing wrong. The running total should start with the first observation (earliest FALLOUT_DATE) and grow from there.</description>
      <pubDate>Thu, 31 Dec 2015 22:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241438#M308917</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T22:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241439#M308918</link>
      <description>&lt;P&gt;I would first try only using one RETAIN for each variable. Multiples, especially when you have one initializing values and the other not may not be quite what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please post code, not pictures of code as we can't copy and paste elements for correction or suggestion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not at all sure why there are statements like:&lt;/P&gt;
&lt;P&gt;Fallout_date=Fallout_date;&lt;/P&gt;
&lt;P&gt;Note_balance_20yr=Note_balance_20yr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Waste of space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241439#M308918</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-31T22:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241441#M308919</link>
      <description>&lt;P&gt;do you have any other proc or data step before or after this code in the workflow??&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241441#M308919</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-31T22:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241442#M308920</link>
      <description>&lt;P&gt;Here is the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as the waste of space issue, I was naming the variable for my new dataset (i.e Fallout_date=Fallout_date).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA FLOWFRED.FMFLOW_LOANSDROPPED_TOT_RPT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET FLOWFRED.FMFLOW_LOANSDROPPED_RUN_TOT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;RETAIN RUNNING_NOTE_BALANCE_15YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;RETAIN RUNNING_NOTE_BALANCE_20YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;RETAIN RUNNING_NOTE_BALANCE_30YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;FALLOUT_DATE=FALLOUT_DATE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NOTE_BALANCE_15YR=NOTE_BALANCE_15YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain RUNNING_NOTE_BALANCE_15YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;RUNNING_NOTE_BALANCE_15YR=SUM(RUNNING_NOTE_BALANCE_15YR,NOTE_BALANCE_15YR);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NOTE_BALANCE_20YR=NOTE_BALANCE_20YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain RUNNING_NOTE_BALANCE_20YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;RUNNING_NOTE_BALANCE_20YR=SUM(RUNNING_NOTE_BALANCE_20YR,NOTE_BALANCE_20YR);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;NOTE_BALANCE_30YR=NOTE_BALANCE_30YR;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain RUNNING_NOTE_BALANCE_30YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;RUNNING_NOTE_BALANCE_30YR=SUM(RUNNING_NOTE_BALANCE_30YR,NOTE_BALANCE_30YR);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data=flowfred.fmflow_loansdropped_tot_rpt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241442#M308920</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T22:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241443#M308921</link>
      <description>&lt;P&gt;Just the proc print I posted below&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241443#M308921</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T22:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241444#M308922</link>
      <description>&lt;P&gt;Can you post snapshot from the first rows of the original dataset "&lt;SPAN&gt;FLOWFRED.FMFLOW_LOANSDROPPED_RUN_TOT"?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241444#M308922</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-31T22:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241448#M308923</link>
      <description>&lt;P&gt;Sure, thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see... the running total works in the original data set (created with proc sql).&amp;nbsp; The problem I have is that the running total doesn't carry forward if there is a missing value in NOTE_BALANCE_15YR.&amp;nbsp; For example, on row 7 there is a missing value for NOTE_BALANCE_15YR so the RUNNING_NOTE_BALANCE_15YR is also missing.&amp;nbsp; I need the RUNNING_NOTE_BALANCE_15YR from row 6 (FALLOUT_DATE 8/12/2015) to carry forward until the next record with a value occurs (row 12, FALLOUT_DATE 8/25/2015).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1339iE13319BE3F7E4B19/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="RunningTotal.JPG" title="RunningTotal.JPG" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241448#M308923</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T22:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241451#M308924</link>
      <description>&lt;P&gt;Now i understand your problem.&lt;/P&gt;
&lt;P&gt;The retained variables are already existing in your original data set and also contains data.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA FLOWFRED.FMFLOW_LOANSDROPPED_TOT_RPT;
    SET FLOWFRED.FMFLOW_LOANSDROPPED_RUN_TOT;
    RETAIN _RUNNING_NOTE_BALANCE_15YR;
    RETAIN _RUNNING_NOTE_BALANCE_20YR;
    RETAIN _RUNNING_NOTE_BALANCE_30YR;
        _RUNNING_NOTE_BALANCE_15YR=SUM(_RUNNING_NOTE_BALANCE_15YR,NOTE_BALANCE_15YR);
        _RUNNING_NOTE_BALANCE_20YR=SUM(_RUNNING_NOTE_BALANCE_20YR,NOTE_BALANCE_20YR);
        _RUNNING_NOTE_BALANCE_30YR=SUM(_RUNNING_NOTE_BALANCE_30YR,NOTE_BALANCE_30YR);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Run the above code and you find the correct result in the new created variables starting with _ .&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241451#M308924</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2015-12-31T22:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241453#M308925</link>
      <description>&lt;P&gt;Does your input data set FLOWFRED.FMFLOW_LOANSDROPPED_RUN_TOT have a variable already named Running_Note_Balance_15Yr? If so, then each time the input set is read it pulls that value from the input set.&lt;/P&gt;
&lt;P&gt;If that is the case then either DROP the existing Running total variables on the set statement (data set option DROP)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; SET FLOWFRED.FMFLOW_LOANSDROPPED_RUN_TOT (drop = RUNNING_NOTE_BALANCE_15YR &amp;nbsp;RUNNING_NOTE_BALANCE_20YR RUNNING_NOTE_BALANCE_30YR&amp;nbsp;);&lt;/P&gt;
&lt;P&gt;or use entirely new variables in your Retain statement and calculations. And use only one retain statement per variable. And all of the variables could be on one statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Retain RUNNING_NOTE_BALANCE_15YR &amp;nbsp;RUNNING_NOTE_BALANCE_20YR RUNNING_NOTE_BALANCE_30YR 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 22:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241453#M308925</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-31T22:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241454#M308926</link>
      <description>&lt;P&gt;Thanks &amp;nbsp;mohamed_zaki&lt;SPAN class="login-bold"&gt;&amp;nbsp;and ballardw... I will try this as soon as I can. &amp;nbsp;I appreciate the help. &amp;nbsp;I will mark this solved asap.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Happy New Year!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2015 23:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241454#M308926</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2015-12-31T23:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241472#M308927</link>
      <description>&lt;P&gt;Thanks again, this worked great.&amp;nbsp; However, now that I have the running totals, I would like to have everything sorted in descending order with the most recent date.&amp;nbsp; That means I would like the running total descending along with the date.&amp;nbsp; I can get the date sorted descending easily but the running total will not sort that way with the date.&amp;nbsp; Any ideas?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jan 2016 17:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241472#M308927</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-01T17:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241476#M308928</link>
      <description>Sort first and then calculate your running total?</description>
      <pubDate>Fri, 01 Jan 2016 20:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241476#M308928</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-01T20:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running Total with Missing Values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241648#M308929</link>
      <description>&lt;P&gt;Thanks Reeza.&amp;nbsp; After taking the sort out of my initial query this worked.&amp;nbsp; I appreciate all of the answers everyone!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 14:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Total-with-Missing-Values/m-p/241648#M308929</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-04T14:11:21Z</dc:date>
    </item>
  </channel>
</rss>

