<?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: Pulling ALL instances of a UniqueID when at least once instance meets required criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866744#M342313</link>
    <description>&lt;P&gt;Thank you to everyone who responded. They all worked and provided the same answers (which is nice as a redundancy check). I've chosen the answer that doesn't require a sort in case other people are looking for a similar solution in the future.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2023 15:03:40 GMT</pubDate>
    <dc:creator>pmaloney</dc:creator>
    <dc:date>2023-03-28T15:03:40Z</dc:date>
    <item>
      <title>Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866627#M342256</link>
      <description>&lt;P&gt;I'm working with meetings data that is formatted as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data: MeetingListHave&lt;/P&gt;&lt;P&gt;MeetingNo&amp;nbsp; &amp;nbsp;PersonNo&amp;nbsp; &amp;nbsp;RoleNo&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; 05&lt;/P&gt;&lt;P&gt;0002&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0003&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0004&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0004&amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;&lt;P&gt;0004&amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;&lt;P&gt;0005&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0006&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0006&amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; 05&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every MeetingNo will always have a PersonNo 01 with RoleNo 01, but after that first person there can any number of people. Each person has exactly one role, but there can be more than one person with the same role (excluding RoleNo 01, which will always be exclusive to PersonNo 01). The available roles are 01,02,03,04,05.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to get a database where only meetings where a person with RoleNo 05 was present. I want all the PersonNos who attended that meeting, not just the person with RoleNo05. Given the dataset above I would want the final data to look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data: MeetingListWant&lt;/P&gt;&lt;P&gt;MeetingNo&amp;nbsp; &amp;nbsp;PersonNo&amp;nbsp; &amp;nbsp;RoleNo&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; 02&lt;/P&gt;&lt;P&gt;0001&amp;nbsp; &amp;nbsp; 03&amp;nbsp; &amp;nbsp; 05&lt;/P&gt;&lt;P&gt;0006&amp;nbsp; &amp;nbsp; 01&amp;nbsp; &amp;nbsp; 01&lt;/P&gt;&lt;P&gt;0006&amp;nbsp; &amp;nbsp; 02&amp;nbsp; &amp;nbsp; 05&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've gotten as far as doing&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sort data=meetinglisthave out=meetinglistsorted; by MeetingNo descending RoleNo; run;&lt;/PRE&gt;&lt;P&gt;so that if there is a person with the 05 role they are always in the first.meetinglistsorted position, but I don't know where to go from there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help you can give, I can provide more details if needed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 20:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866627#M342256</guid>
      <dc:creator>pmaloney</dc:creator>
      <dc:date>2023-03-27T20:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866646#M342266</link>
      <description>&lt;P&gt;Something like this should give you what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as 
  select * 
  from meetinglisthave
  where MeetingNo in
  (select MeetingNo 
   from meetinglisthave
   where RoleNo = '05'
  );
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2023 22:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866646#M342266</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-03-27T22:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866657#M342270</link>
      <description>&lt;P&gt;The MAX() of a series of Boolean expression is TRUE if ANY of them were true.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
  select * MeetingListHave&lt;BR /&gt;  group by &lt;SPAN&gt;MeetingNo&lt;/SPAN&gt;
  having max(RoleNo='05')
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2023 00:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866657#M342270</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-28T00:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866692#M342286</link>
      <description>&lt;P&gt;Given that your dataset is already sorted, this will outperform other methods:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want,
do until (last.meetingno);
  set have;
  by meetingno;
  if roleno = "05" then flag = 1;
end;
do until (last.meetingno);
  set have;
  by meetingno;
  if flag then output;
end;
drop flag;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Known as the "DOW loop".&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 08:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866692#M342286</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-28T08:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866744#M342313</link>
      <description>&lt;P&gt;Thank you to everyone who responded. They all worked and provided the same answers (which is nice as a redundancy check). I've chosen the answer that doesn't require a sort in case other people are looking for a similar solution in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 15:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866744#M342313</guid>
      <dc:creator>pmaloney</dc:creator>
      <dc:date>2023-03-28T15:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling ALL instances of a UniqueID when at least once instance meets required criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866781#M342327</link>
      <description>&lt;P&gt;Note that all methods require sorting; it's just that SQL does it "under the hood". With larger datasets, comparing the methods for performance is recommended.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 17:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-ALL-instances-of-a-UniqueID-when-at-least-once-instance/m-p/866781#M342327</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-28T17:32:49Z</dc:date>
    </item>
  </channel>
</rss>

