<?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: Replacing missing values with previous value in groups-How to reset retain function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406385#M98948</link>
    <description>&lt;P&gt;Thanks for the reply &lt;SPAN class="login-bold"&gt;Astounding&lt;/SPAN&gt;. I have separated the stocks in different tables so no need for the CUSIP.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Oct 2017 19:15:42 GMT</pubDate>
    <dc:creator>Efthymios</dc:creator>
    <dc:date>2017-10-22T19:15:42Z</dc:date>
    <item>
      <title>Replacing missing values with previous value in groups-How to reset retain function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406381#M98945</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question regarding replacing missing values with previous value. I know that this topic has been covered but it seems I can't get it right. My dataset consists of Bid and Ask quotes and is sorted by date and time. I want to replace the missing quotes with the previous available but doing so separately for each date. For example I don't want the quote from the previous date to carry into the next. I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;set test1;&lt;BR /&gt;by Date;&lt;BR /&gt;retain Bidint;&lt;BR /&gt;if first.date then do;&lt;BR /&gt;if Bid&amp;gt;. then Bidint=Bid;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But what it does it retaining only the first observation of each&amp;nbsp;date. What I really want is to reset retain function at the beginning of each date.&amp;nbsp; Thank you in advance&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 17:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406381#M98945</guid>
      <dc:creator>Efthymios</dc:creator>
      <dc:date>2017-10-22T17:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing missing values with previous value in groups-How to reset retain function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406383#M98946</link>
      <description>&lt;P&gt;Slightly change the logic:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
set test1;
by Date;
retain Bidint;
if first.date or Bid ne . then Bidint = Bid;
if not first.date and bid = . then bid = bidint;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Oct 2017 17:59:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406383#M98946</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-22T17:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing missing values with previous value in groups-How to reset retain function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406384#M98947</link>
      <description>&lt;P&gt;It's not 100% clear where you are heading here.&amp;nbsp; Which variable is supposed to hold which values?&amp;nbsp; And is there only one CUSIP per data set?&amp;nbsp; Here's one possibility:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;/P&gt;
&lt;P&gt;set test1;&lt;/P&gt;
&lt;P&gt;by date;&lt;/P&gt;
&lt;P&gt;retain BidInt;&lt;/P&gt;
&lt;P&gt;if first.date or bid &amp;gt; . then BidInt = bid;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For this code, BIDINT will hold the most recent nonmissing bid, with missing BID values replaced by the most recent BID values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course if you have multiple CUSIPs, you will need to add a variable to the BY statement.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 18:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406384#M98947</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-22T18:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing missing values with previous value in groups-How to reset retain function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406385#M98948</link>
      <description>&lt;P&gt;Thanks for the reply &lt;SPAN class="login-bold"&gt;Astounding&lt;/SPAN&gt;. I have separated the stocks in different tables so no need for the CUSIP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 19:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406385#M98948</guid>
      <dc:creator>Efthymios</dc:creator>
      <dc:date>2017-10-22T19:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing missing values with previous value in groups-How to reset retain function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406386#M98949</link>
      <description>&lt;P&gt;Thanks KurtBremser. Tried also your code and it works. Much appreciate the quick response&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2017 19:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-missing-values-with-previous-value-in-groups-How-to/m-p/406386#M98949</guid>
      <dc:creator>Efthymios</dc:creator>
      <dc:date>2017-10-22T19:16:59Z</dc:date>
    </item>
  </channel>
</rss>

