<?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: Flag Duplicate Based on Multiple Criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698433#M213605</link>
    <description>"oldest" would be the lowest MOD (smallest integer) for that particular VIN, if the VIN appears more than once in the dataset.&lt;BR /&gt;&lt;BR /&gt;What I have is the first 3 columns, what I want is the Flag column to be added based on the logic provided above. "0" indicates no flag, 1 indicates a flag.</description>
    <pubDate>Thu, 12 Nov 2020 16:19:37 GMT</pubDate>
    <dc:creator>BlayLay</dc:creator>
    <dc:date>2020-11-12T16:19:37Z</dc:date>
    <item>
      <title>Flag Duplicate Based on Multiple Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698404#M213585</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this question, I'll provide a dummy table to try and explain what I'm looking for. Based on the below table, what I'm looking to do is for TYPE = NEW VEHICLE, check the VIN and if it's a duplicate, flag the oldest MOD.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;VIN&lt;/TD&gt;&lt;TD&gt;MOD&lt;/TD&gt;&lt;TD&gt;TYPE&lt;/TD&gt;&lt;TD&gt;FLAG&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;33476&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;NEW VEHICLE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;33476&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;NEW VEHICLE&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;38159&lt;/TD&gt;&lt;TD&gt;16&lt;/TD&gt;&lt;TD&gt;OLD VEHICLE&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;39138&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;OLD VEHICLE&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;36745&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;NEW VEHICLE&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;36745&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;NEW VEHICLE&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw a way to delete the last.var or flag by checking a single column for duplicates, but this is a bit more complex than I'm familiar with and requires more logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 15:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698404#M213585</guid>
      <dc:creator>BlayLay</dc:creator>
      <dc:date>2020-11-12T15:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Duplicate Based on Multiple Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698414#M213592</link>
      <description>&lt;P&gt;I suggest that you provide how we identify&amp;nbsp; the "oldest" of anything given that data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second provide data in the form of "what I have" and "what I want".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, best is to provide the data in the form of a working data step so we can recreate your data and test code.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 15:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698414#M213592</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-12T15:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Duplicate Based on Multiple Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698433#M213605</link>
      <description>"oldest" would be the lowest MOD (smallest integer) for that particular VIN, if the VIN appears more than once in the dataset.&lt;BR /&gt;&lt;BR /&gt;What I have is the first 3 columns, what I want is the Flag column to be added based on the logic provided above. "0" indicates no flag, 1 indicates a flag.</description>
      <pubDate>Thu, 12 Nov 2020 16:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698433#M213605</guid>
      <dc:creator>BlayLay</dc:creator>
      <dc:date>2020-11-12T16:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Flag Duplicate Based on Multiple Criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698453#M213617</link>
      <description>&lt;P&gt;This seems to work for your example data:&lt;/P&gt;
&lt;PRE&gt;Proc sort data=have;
   by vin type mod;
run;

data want;
   set have;
   by vin type mod;
   if type = 'NEW VEHICLE' and first.Type then flag=1;
   else flag=0;
run;&lt;/PRE&gt;
&lt;P&gt;However, if you have mix of Old and New and mod values for the same vin no promises.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 17:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-Duplicate-Based-on-Multiple-Criteria/m-p/698453#M213617</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-12T17:39:10Z</dc:date>
    </item>
  </channel>
</rss>

