<?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: Multiple data outcomes retained - Same ID in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiple-data-outcomes-retained-Same-ID/m-p/535569#M6506</link>
    <description>&lt;P&gt;Given that you have created your original data set, the programming should be short:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first_restricted all_others;
set original;
by key outcome notsorted;
if first.outcome and outcome = "RESTRICTED" 
then output first_restricted;
else output all_others;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Feb 2019 12:54:02 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-14T12:54:02Z</dc:date>
    <item>
      <title>Multiple data outcomes retained - Same ID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-data-outcomes-retained-Same-ID/m-p/535559#M6504</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to produce an outcome which would keep multiple outcomes from the same ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example shows the original dataset. This has shown 3 IDs each with a time stamp on and the outcome from that time stamp. What i am trying to do is to keep when the outcome is &lt;STRONG&gt;restricted&lt;/STRONG&gt; but not for just the first occasion, this could be restricted either on the first occastion or this could be &lt;STRONG&gt;restricted&lt;/STRONG&gt; after the prior decision was classified as &lt;STRONG&gt;access&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; original;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; KEY $ Outcome $ Time $ ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id=_n_;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 ACCESS 2&lt;/P&gt;&lt;P&gt;1 RESTRICTED 4&lt;/P&gt;&lt;P&gt;1 ACCESS 6&lt;/P&gt;&lt;P&gt;1 RESTRICTED 8&lt;/P&gt;&lt;P&gt;1 RESTRICTED 10&lt;/P&gt;&lt;P&gt;2 ACCESS 2&lt;/P&gt;&lt;P&gt;2 RESTRICTED 4&lt;/P&gt;&lt;P&gt;2 RESTRICTED 6&lt;/P&gt;&lt;P&gt;2 RESTRICTED 8&lt;/P&gt;&lt;P&gt;2 RESTRICTED 10&lt;/P&gt;&lt;P&gt;3 RESTRICTED 2&lt;/P&gt;&lt;P&gt;3 ACCESS 4&lt;/P&gt;&lt;P&gt;3 RESTRICTED 6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The outcome below shows the final outcome i would wish to produce. This would pull out only the relevant data when the data has been classified as restricted and is either the first occasion or has superseded where the same ID had show access prior to this. Initially I have tried a retain but due to the sort and nature this didnt seem to work. I have also thought about a lag function to view the outcome prior and I couldnt get this to work,&amp;nbsp;I tried via&amp;nbsp;matching the outcome previously to the outcome now. This would also not work for when outcome is &lt;STRONG&gt;restricted &lt;/STRONG&gt;on the first example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; output_1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; KEY $ Outcome $ Time $ ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id=_n_;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 RESTRICTED 4&lt;/P&gt;&lt;P&gt;1 RESTRICTED 8&lt;/P&gt;&lt;P&gt;2 RESTRICTED 4&lt;/P&gt;&lt;P&gt;3 RESTRICTED 2&lt;/P&gt;&lt;P&gt;3 RESTRICTED 6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If possible would it possible to output the remaining information in another datasets. Such as the one below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; output_2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; KEY $ Outcome $ Time $ ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id=_n_;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 ACCESS 2&lt;/P&gt;&lt;P&gt;1 ACCESS 6&lt;/P&gt;&lt;P&gt;1 RESTRICTED 10&lt;/P&gt;&lt;P&gt;2 ACCESS 2&lt;/P&gt;&lt;P&gt;2 RESTRICTED 6&lt;/P&gt;&lt;P&gt;2 RESTRICTED 8&lt;/P&gt;&lt;P&gt;2 RESTRICTED 10&lt;/P&gt;&lt;P&gt;3 ACCESS 4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 12:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-data-outcomes-retained-Same-ID/m-p/535559#M6504</guid>
      <dc:creator>Mick_bill</dc:creator>
      <dc:date>2019-02-14T12:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple data outcomes retained - Same ID</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiple-data-outcomes-retained-Same-ID/m-p/535569#M6506</link>
      <description>&lt;P&gt;Given that you have created your original data set, the programming should be short:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first_restricted all_others;
set original;
by key outcome notsorted;
if first.outcome and outcome = "RESTRICTED" 
then output first_restricted;
else output all_others;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Feb 2019 12:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiple-data-outcomes-retained-Same-ID/m-p/535569#M6506</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-14T12:54:02Z</dc:date>
    </item>
  </channel>
</rss>

