<?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: How to remove duplicate values inside a group? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735180#M38579</link>
    <description>&lt;P&gt;Here you go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input type $ quarter phase;
  datalines;
K-11 202001 1
K-11 202101 2
K-11 202003
K-11 202004 3
K-12 202101 3
K-12 202102 1
K-12 202103 1
K-12 202103 1
K-13 202003 2
K-13 202103 3
K-13 202103 2
K-13 202103 2
;

proc sort data=have out=want;
  by type quarter descending phase;
run;

data want;
  set want;
  by type quarter;

  if first.quarter;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Apr 2021 07:29:34 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-04-19T07:29:34Z</dc:date>
    <item>
      <title>How to remove duplicate values inside a group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735178#M38578</link>
      <description>&lt;P&gt;I'm trying to do the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If a quarter occurs more then once in a type I want to keep only the quarter with the highest phase. The other ones need to be deleted.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This is the data I have (in reality much bigger!):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines;
input type $ quarter phase;
datalines;
K-11 202001 1
K-11 202101 2
K-11 202003
K-11 202004 3
K-12 202101 3
K-12 202102 1
K-12 202103 1
K-12 202103 1
K-13 202003 2
K-13 202103 3
K-13 202103 2
K-13 202103 2
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the data I want:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;K-11 202001 1
K-11 202101 2
K-11 202003
K-11 202004 3
K-12 202101 3
K-12 202102 1
K-12 202103 1
K-13 202003 2
K-13 202103 3
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Apr 2021 07:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735178#M38578</guid>
      <dc:creator>Andalusia</dc:creator>
      <dc:date>2021-04-19T07:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values inside a group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735180#M38579</link>
      <description>&lt;P&gt;Here you go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input type $ quarter phase;
  datalines;
K-11 202001 1
K-11 202101 2
K-11 202003
K-11 202004 3
K-12 202101 3
K-12 202102 1
K-12 202103 1
K-12 202103 1
K-13 202003 2
K-13 202103 3
K-13 202103 2
K-13 202103 2
;

proc sort data=have out=want;
  by type quarter descending phase;
run;

data want;
  set want;
  by type quarter;

  if first.quarter;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Apr 2021 07:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735180#M38579</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-19T07:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values inside a group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735181#M38580</link>
      <description>&lt;P&gt;Or here a 2nd option to achieve the same. Bit special but it has the advantage that SAS "knows" that want is sorted which can be beneficial for performance for downstream processing requiring data sorted this way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input type $ quarter phase;
  datalines;
K-11 202001 1
K-11 202101 2
K-11 202003
K-11 202004 3
K-12 202101 3
K-12 202102 1
K-12 202103 1
K-12 202103 1
K-13 202003 2
K-13 202103 3
K-13 202103 2
K-13 202103 2
;

proc sort data=have out=want;
  by type quarter descending phase;
run;

proc sort data=want out=want nodupkey;
  by type quarter;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Apr 2021 07:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-remove-duplicate-values-inside-a-group/m-p/735181#M38580</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-19T07:33:10Z</dc:date>
    </item>
  </channel>
</rss>

