<?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: Retaining variable from previous observation when variable is missing in current observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242405#M309040</link>
    <description>&lt;P&gt;If you were to search for an answer, the term "LOCF" would be a good starting place. &amp;nbsp; You might even find similar questions and solutions in this forum in recent months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You begin the final step like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATA FLOWFRED.FMFLOW_PIPELINE_HISTSUM_CHART;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET FLOWFRED.FMFLOW_PIPELINE_HISTSUM_ARCHIVE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain PREV_TOTAL_NOTE_BALANCE_15YR 0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could continue it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if TOTAL_NOTE_BALANCE_15YR &amp;gt; . then PREV_TOTAL_NOTE_BALANCE_15YR = TOTAL_NOTE_BALANCE_15YR;&lt;/P&gt;
&lt;P&gt;else TOTAL_NOTE_BALANCE_15YR = PREV_TOTAL_NOTE_BALANCE_15YR;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need to apply similar logic for the remaining 3 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jan 2016 16:56:44 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-01-08T16:56:44Z</dc:date>
    <item>
      <title>Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242386#M309036</link>
      <description>&lt;P&gt;Hello.&amp;nbsp; I am trying to figure out how to retain an amount from a previous observation when there is no amount available for the current observation.&amp;nbsp; In my example, on 12/31 there was an amount for $43,011,231 for the TOTAL_NOTE_BALANCE_15YR variable.&amp;nbsp; On 1/1 there was a missing variable for that field.&amp;nbsp; In that instance, I would like to carry forward the value from 12/31 and continue that through each day until there is a new value (so until we get to 1/4 when there is a new amount for $43,473,936.&amp;nbsp; I would like to be able to do this for all variables in the observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried using the retain statement with no luck.&amp;nbsp; Not sure where to go from here.&amp;nbsp; Any help would be appreciated.&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/1393iD377D89F6C9A1EB4/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="Capture.JPG" title="Capture.JPG" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 15:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242386#M309036</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-08T15:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242387#M309037</link>
      <description>&lt;P&gt;Attaching your current program or log would help.&lt;/P&gt;
&lt;P&gt;Basically, you should retain a separate&amp;nbsp;(new) variable, and conditionally assign (to and from) it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 15:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242387#M309037</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-01-08T15:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242390#M309038</link>
      <description>&lt;P&gt;Please post sample data, as text, not images since we can't paste images into SAS to try anything.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 15:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242390#M309038</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-08T15:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242396#M309039</link>
      <description>&lt;P&gt;Thanks guys.&amp;nbsp; Here is the code I have been working with.&amp;nbsp; I also attached an excel file with the data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;insert into FLOWFRED.FMFLOW_PIPELINE_HISTSUM_ARCHIVE&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;select&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;d.Date,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.DATE_ADDED,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.PCT_TOTAL_UPB_15YR,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.PCT_TOTAL_UPB_20YR,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.PCT_TOTAL_UPB_30YR,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.TOTAL_NOTE_BALANCE_15YR,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.TOTAL_NOTE_BALANCE_20YR,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ln.TOTAL_NOTE_BALANCE_30YR&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;from MSRCOM.MSRCOM_DATE_TABLE d&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;left join FLOWFRED.FMFLOW_LOANSINPIPELINE_HISTSUM ln on ln.DATE_ADDED = d.Date&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;left join FLOWFRED.FMFLOW_BEGIN_DATES bd on bd.DATE_MOST_RECENT = ln.DATE_ADDED&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;/*left join FLOWFRED.FMFLOW_PIPELINE_HISTSUM_UPDARC ar on ar.Date = d.Date*/&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;where d.Date &amp;lt;= bd.DATE_MOST_RECENT;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;DATA FLOWFRED.FMFLOW_PIPELINE_HISTSUM_CHART;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET FLOWFRED.FMFLOW_PIPELINE_HISTSUM_ARCHIVE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain PREV_TOTAL_NOTE_BALANCE_15YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain PREV_TOTAL_NOTE_BALANCE_20YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain PREV_TOTAL_NOTE_BALANCE_30YR 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;IF MISSING(TOTAL_NOTE_BALANCE_15YR) = 1 THEN TOTAL_NOTE_BALANCE_15YR=SUM(PREV_RUNNING_NOTE_BALANCE_15YR,TOTAL_NOTE_BALANCE_15YR);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ELSE TOTAL_NOTE_BALANCE_15YR=TOTAL_NOTE_BALANCE_15YR;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 16:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242396#M309039</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-08T16:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242405#M309040</link>
      <description>&lt;P&gt;If you were to search for an answer, the term "LOCF" would be a good starting place. &amp;nbsp; You might even find similar questions and solutions in this forum in recent months.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You begin the final step like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATA FLOWFRED.FMFLOW_PIPELINE_HISTSUM_CHART;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SET FLOWFRED.FMFLOW_PIPELINE_HISTSUM_ARCHIVE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;retain PREV_TOTAL_NOTE_BALANCE_15YR 0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could continue it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if TOTAL_NOTE_BALANCE_15YR &amp;gt; . then PREV_TOTAL_NOTE_BALANCE_15YR = TOTAL_NOTE_BALANCE_15YR;&lt;/P&gt;
&lt;P&gt;else TOTAL_NOTE_BALANCE_15YR = PREV_TOTAL_NOTE_BALANCE_15YR;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need to apply similar logic for the remaining 3 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 16:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242405#M309040</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-08T16:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242431#M309041</link>
      <description>&lt;P&gt;Is there a unique identifier you are leaving out of your sample data?&amp;nbsp; If you have an ID you can use this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;update have(obs=0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; have;&lt;BR /&gt;by id;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 18:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242431#M309041</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2016-01-08T18:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242476#M309042</link>
      <description>&lt;P&gt;Thanks Astounding....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I change my code to run this I get all zero's in that column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA FLOWFRED.FMFLOW_PIPELINE_HISTSUM_CHART;
	SET FLOWFRED.FMFLOW_PIPELINE_HISTSUM_ARCHIVE;
		retain PREV_TOTAL_NOTE_BALANCE_15YR 0;
		IF TOTAL_NOTE_BALANCE_15YR &amp;gt; . THEN PREV_RUNNING_NOTE_BALANCE_15YR=TOTAL_NOTE_BALANCE_15YR;
				ELSE TOTAL_NOTE_BALANCE_15YR=PREV_TOTAL_NOTE_BALANCE_15YR;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I attached new sample data from this run.&amp;nbsp; As you can see, the PREV_TOTAL_NOTE_BALANCE_15YR variable shows 0 for every observation.&amp;nbsp; The PREV_RUNNING_NOTE_BALANCE_15YR is only populating for the observations with data.&amp;nbsp; I need the data to carry over from the previous observation if the current is missing. So, 12/31/15 data (identical) through 1/3/2016 since those observations have no data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 21:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242476#M309042</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-08T21:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242498#M309043</link>
      <description>&lt;P&gt;I think you may be thinking of&amp;nbsp;or naming one or more variables inconsisitently.&lt;/P&gt;
&lt;P&gt;PREV_RUNNING_NOTE_BALANCE_15YR is not in your input data and is not retained and nothing is done withit except the assignment.&lt;/P&gt;
&lt;P&gt;So what is the purpose of this variable?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 23:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242498#M309043</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-08T23:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242500#M309044</link>
      <description>&lt;P&gt;My understanding is that I would need to create it to hold the previous obvservation's variable. &amp;nbsp;If it is not necessary then it is not needed. &amp;nbsp;I am sure I was making it more complicated than it needs to be but I just can't get there.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 23:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242500#M309044</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-08T23:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242648#M309045</link>
      <description>&lt;P&gt;Code not tested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last);
   set have end=last;
 end;
   NEW_TOTAL_NOTE_BALANCE_15YR =TOTAL_NOTE_BALANCE_15YR ;
 do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last);
   set have end=last;
   output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2016 04:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242648#M309045</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-11T04:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242704#M309046</link>
      <description>&lt;P&gt;Thank you Xia,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a lot closer, however, it looks like it is populating the value of the next observation rather than the previous.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1409i862CBED2D5CDABFB/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="Capture.JPG" title="Capture.JPG" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 14:08:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242704#M309046</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-11T14:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242743#M309047</link>
      <description>&lt;P&gt;Also, I have 2 more variables that I would need to do the same thing on for the same observations.&amp;nbsp; This seems to only look at TOTAL_NOTE_BALANCE_15YR.&amp;nbsp; How would I make this work for all of the variables and still look back at the previous number?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 16:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242743#M309047</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-11T16:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242771#M309048</link>
      <description>&lt;P&gt;You just typed in the wrong variable is all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;
		&lt;SPAN class="token keyword"&gt;IF&lt;/SPAN&gt; TOTAL_NOTE_BALANCE_15YR &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;THEN&lt;/SPAN&gt; PREV_RUNNING_NOTE_BALANCE_15YR&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
				&lt;SPAN class="token keyword"&gt;ELSE&lt;/SPAN&gt; TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;PREV_TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;
		&lt;SPAN class="token keyword"&gt;IF&lt;/SPAN&gt; TOTAL_NOTE_BALANCE_15YR &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;THEN&lt;/SPAN&gt; PREV_TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
				&lt;SPAN class="token keyword"&gt;ELSE&lt;/SPAN&gt; TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;PREV_TOTAL_NOTE_BALANCE_15YR&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 17:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242771#M309048</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-11T17:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242776#M309049</link>
      <description>&lt;P&gt;I can't believe I missed that.&amp;nbsp; Sometimes it just takes a second pair of eyes I guess.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I reran this and it works perfectly.&amp;nbsp; Thank you to everyone in this thread for your help.&amp;nbsp; It is much appreciated.&amp;nbsp; I love these forums.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 18:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242776#M309049</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-01-11T18:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242807#M309050</link>
      <description>&lt;P&gt;Add additional code patterned on that code that works for one value. Use variable names that make sense to you.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242807#M309050</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-11T20:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242840#M309051</link>
      <description>&lt;P&gt;I know what is going on .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input TOTAL_NOTE_BALANCE_15YR ;
cards;
45746
43473
.
.
.
43011
;
run;

data want;
 do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last1);
   set have end=last1;
 end; 
   NEW_TOTAL_NOTE_BALANCE_15YR =TOTAL_NOTE_BALANCE_15YR ;
 do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last2);
   set have end=last2; 
   output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2016 01:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/242840#M309051</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-12T01:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243121#M309052</link>
      <description>Hi Xia, How two DoW-loop is working here? Can you explain little bit? Thanks !</description>
      <pubDate>Wed, 13 Jan 2016 04:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243121#M309052</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-01-13T04:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243131#M309053</link>
      <description>&lt;P&gt;&lt;STRONG&gt;When _n_ eq 1 :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; the first do until will rolling here&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;45746 &amp;lt;---
43473
.
.
.
43011
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;assign 45746 to new variable.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; the second&amp;nbsp;do until will output this obs , so new variable retain&amp;nbsp;45746 and export to WANT dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;When _n_ eq 2 :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; the first do until will rolling here&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;45746 
43473 &amp;lt;---
.
.
.
43011
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;assign 43473 &amp;nbsp;to new variable.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the second &amp;nbsp;do until will output this obs , so new variable retain 43473&amp;nbsp;and export to WANT dataset.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;When _n_ eq 3 :&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; the first do until will rolling here&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;45746 
43473 
&lt;STRONG&gt;.
.
.
43011 &amp;lt;---
&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;assign 43011&amp;nbsp;to new variable.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the second &amp;nbsp;do until will output&lt;STRONG&gt; the following 4&amp;nbsp;obs utill&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;43011&amp;nbsp;&lt;/STRONG&gt;, so new variable retain 43011&amp;nbsp;and export to WANT dataset &lt;STRONG&gt;with &amp;nbsp;these four obs .&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;etc...........&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 08:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243131#M309053</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-13T08:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243201#M309054</link>
      <description>&lt;P&gt;Thanks, Xia. &amp;nbsp;So it is kind of nested DoW loop?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 14:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243201#M309054</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-01-13T14:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Retaining variable from previous observation when variable is missing in current observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243371#M309055</link>
      <description>&lt;P&gt;Yes. It is DOW skill has been mentioned by many people and many times.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 00:59:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retaining-variable-from-previous-observation-when-variable-is/m-p/243371#M309055</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-14T00:59:08Z</dc:date>
    </item>
  </channel>
</rss>

