<?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: last observations with last group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706249#M216755</link>
    <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines dlm=',' dsd missover;
input ID	ON_OFF :$8.	CATEGORY :$8.	Group:8.;
datalines;
1,OFF,P,1
1,ON,G,2
2,OFF,C,1
2,OFF,C,1
3,OFF,O,1
3,OFF,R,2
4,OFF,C,2
4,ON,G,2
5,OFF,S,1
5,OFF,R,2
5,ON,G,2
6,ON,S,1
6,ON,S,3
6,ON,R,3
;

data want;
   do until (last.id);
      set have(rename=group=g);
      by id;
   end;
   do until (last.id);
      set have;
      by id;
      if group = g then output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Dec 2020 08:58:57 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-12-16T08:58:57Z</dc:date>
    <item>
      <title>last observations with last group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706246#M216753</link>
      <description>&lt;P&gt;I am doing the below step to get last ID but if the group has more than one number with last than i want multiple i.e if for ID the group has 3 as last record adn if i have multiple 3's than i want them all. CUrrently i dont get by the below step, Can anyone help me&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines dlm=',' dsd missover;
input ID	ON_OFF :$8.	CATEGORY :$8.	Group:8.;
datalines;
1,OFF,P,1
1,ON,G,2
2,OFF,C,1
2,OFF,C,1
3,OFF,O,1
3,OFF,R,2
4,OFF,C,2
4,ON,G,2
5,OFF,S,1
5,OFF,R,2
5,ON,G,2
6,ON,S,1
6,ON,S,3
6,ON,R,3
;
run;

data want;
   set have;
   by ID group notsorted;
   if last.ID;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2020 08:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706246#M216753</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2020-12-16T08:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: last observations with last group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706249#M216755</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
infile datalines dlm=',' dsd missover;
input ID	ON_OFF :$8.	CATEGORY :$8.	Group:8.;
datalines;
1,OFF,P,1
1,ON,G,2
2,OFF,C,1
2,OFF,C,1
3,OFF,O,1
3,OFF,R,2
4,OFF,C,2
4,ON,G,2
5,OFF,S,1
5,OFF,R,2
5,ON,G,2
6,ON,S,1
6,ON,S,3
6,ON,R,3
;

data want;
   do until (last.id);
      set have(rename=group=g);
      by id;
   end;
   do until (last.id);
      set have;
      by id;
      if group = g then output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2020 08:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706249#M216755</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-12-16T08:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: last observations with last group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706250#M216756</link>
      <description>&lt;P&gt;This?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select *
  from have
  group by id
  having group = max(group)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until (last.id);
  set have;
  by id;
  maxgroup = max(maxgroup,group);
end;
do until (last.id);
  set have;
  by id;
  if group = maxgroup then output;
end;
drop maxgroup;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2020 09:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-observations-with-last-group/m-p/706250#M216756</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-16T09:01:17Z</dc:date>
    </item>
  </channel>
</rss>

