<?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: Need help with 'Retain' statement please. in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212793#M15968</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works perfectly.&amp;nbsp; Thanks Mark, you're the best.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jul 2015 19:11:21 GMT</pubDate>
    <dc:creator>BHinPHX</dc:creator>
    <dc:date>2015-07-28T19:11:21Z</dc:date>
    <item>
      <title>Need help with 'Retain' statement please.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212791#M15966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an EG data set with three fields: CUST, EVENT, and STATUS.&amp;nbsp; EVENT is a chronologic counter of events by CUST and STATUS is an assigned field based on some if-then-else.&amp;nbsp; What I want to do is assign a value of "BAD" to all subsequent blank STATUS fields - but only where the last STATUS value = 'BAD'.&amp;nbsp; I'm using a RETAIN statement (code is below).&amp;nbsp; The problem is this logic captures the last 'not missing' value and copies it down so in the example below, customer 789 would have a STATUS value of "AVERAGE" for event 3 and 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to add additional criteria so I only use a 'not missing' value of "BAD"?&amp;nbsp; I've tried several things but none work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Current results:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CUST EVENT STATUS&lt;/P&gt;&lt;P&gt;123456 1 GOOD&lt;/P&gt;&lt;P&gt;123456 2 BAD&lt;/P&gt;&lt;P&gt;123456 3 &lt;/P&gt;&lt;P&gt;123456 4 &lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 GOOD&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 AVERAGE&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Desired results:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CUST EVENT STATUS&lt;/P&gt;&lt;P&gt;123456 1 GOOD&lt;/P&gt;&lt;P&gt;123456 2 BAD&lt;/P&gt;&lt;P&gt;123456 3 BAD&lt;/P&gt;&lt;P&gt;123456 4 BAD&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 GOOD&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2 AVERAGE&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;789&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA VALIDATION;&lt;/P&gt;&lt;P&gt;SET VALIDATION;&lt;/P&gt;&lt;P&gt;RETAIN _STATUS;&lt;/P&gt;&lt;P&gt;BY CUST;&lt;/P&gt;&lt;P&gt;IF NOT MISSING(STATUS) THEN _STATUS=STATUS;&lt;/P&gt;&lt;P&gt;ELSE STATUS=_STATUS;&lt;/P&gt;&lt;P&gt; DROP _STATUS;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 18:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212791#M15966</guid>
      <dc:creator>BHinPHX</dc:creator>
      <dc:date>2015-07-28T18:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with 'Retain' statement please.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212792#M15967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;input CUST$ EVENT$ STATUS$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;123456,1,GOOD&lt;/P&gt;&lt;P&gt;123456,2,BAD&lt;/P&gt;&lt;P&gt;123456,3,&lt;/P&gt;&lt;P&gt;123456,4,&lt;/P&gt;&lt;P&gt;789,1,GOOD&lt;/P&gt;&lt;P&gt;789,2,AVERAGE&lt;/P&gt;&lt;P&gt;789,3,&lt;/P&gt;&lt;P&gt;789,4,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;retain _status;&lt;/P&gt;&lt;P&gt;if not missing(status) then _status = status;&lt;/P&gt;&lt;P&gt;if _status = 'BAD' then status = _status;&lt;/P&gt;&lt;P&gt;drop _:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note:&amp;nbsp; The first time I went through this I did the same exact thing you did, same thought process.&amp;nbsp; If you don't drop the unwanted variable it will give you a better visual of what is happening and help you work through it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Mark Johnson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 18:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212792#M15967</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-07-28T18:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with 'Retain' statement please.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212793#M15968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works perfectly.&amp;nbsp; Thanks Mark, you're the best.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 19:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Need-help-with-Retain-statement-please/m-p/212793#M15968</guid>
      <dc:creator>BHinPHX</dc:creator>
      <dc:date>2015-07-28T19:11:21Z</dc:date>
    </item>
  </channel>
</rss>

