<?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: Duplicate field in EG in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757544#M39209</link>
    <description>&lt;P&gt;Thanks Reeza. In the last I would be removing the duplicates. But after glancing over the data with dups I choose whether to keep the dup&lt;/P&gt;
&lt;P&gt;value or exclude the other dup value that is blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like both options :&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;maximum per group via a CASE statement, and&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ranking&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have tried one or the other depending on the needs of the project and find them useful but just to avoid a few extra steps I was looking to create something quicker for DUPS in query builder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But if no such concept (program Code) could be done in query builder then I'll make my peace with program code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for suggestions.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jul 2021 22:23:40 GMT</pubDate>
    <dc:creator>sasuser_sk</dc:creator>
    <dc:date>2021-07-27T22:23:40Z</dc:date>
    <item>
      <title>Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757528#M39202</link>
      <description>&lt;P&gt;Hi Everyone. I have this data below. How can I create Duplicate field in EG based on ID. This is how I did in program code. Thank you.&lt;/P&gt;
&lt;P&gt;data DUPS;&lt;BR /&gt;set WORK.ACTIVE_RECORDS ;&lt;BR /&gt;BY ID;&lt;BR /&gt;format DUPLICATE $CHAR30.;&lt;BR /&gt;IF (FIRST.ID) THEN DUPLICATE='';&lt;BR /&gt;ELSE DUPLICATE = 'DUPS';&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID CATEGORY SUB_ID DUPLICATE&lt;BR /&gt;5692 C1 7000001 &lt;BR /&gt;5986 C2 7000002 &lt;BR /&gt;6050 C1 7000003 &lt;BR /&gt;6080 C2 7000004 &lt;BR /&gt;7789 C4 7000005 &lt;BR /&gt;7789 C4 7000006 DUPS&lt;BR /&gt;7790 C1 7000007 &lt;BR /&gt;7791 C1 7000008 &lt;BR /&gt;8695 C1 7000009 &lt;BR /&gt;8695 C2 7000010 DUPS&lt;BR /&gt;9526 C1 7000011 &lt;BR /&gt;9528 C1 7000012 &lt;BR /&gt;9598 C1 7000013 &lt;BR /&gt;9598 C2 7000014 DUPS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757528#M39202</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T21:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757530#M39203</link>
      <description>&lt;P&gt;Are you asking how to create it using the GUI then? Or are you asking how to make your code more efficient or alternative code solutions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311117"&gt;@sasuser_sk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Everyone. I have this data below. How can I create Duplicate field in EG based on ID. This is how I did in program code. Thank you.&lt;/P&gt;
&lt;P&gt;data DUPS;&lt;BR /&gt;set WORK.ACTIVE_RECORDS ;&lt;BR /&gt;BY ID;&lt;BR /&gt;format DUPLICATE $CHAR30.;&lt;BR /&gt;IF (FIRST.ID) THEN DUPLICATE='';&lt;BR /&gt;ELSE DUPLICATE = 'DUPS';&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID CATEGORY SUB_ID DUPLICATE&lt;BR /&gt;5692 C1 7000001 &lt;BR /&gt;5986 C2 7000002 &lt;BR /&gt;6050 C1 7000003 &lt;BR /&gt;6080 C2 7000004 &lt;BR /&gt;7789 C4 7000005 &lt;BR /&gt;7789 C4 7000006 DUPS&lt;BR /&gt;7790 C1 7000007 &lt;BR /&gt;7791 C1 7000008 &lt;BR /&gt;8695 C1 7000009 &lt;BR /&gt;8695 C2 7000010 DUPS&lt;BR /&gt;9526 C1 7000011 &lt;BR /&gt;9528 C1 7000012 &lt;BR /&gt;9598 C1 7000013 &lt;BR /&gt;9598 C2 7000014 DUPS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757530#M39203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-27T21:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757531#M39204</link>
      <description>&lt;P&gt;Your program will work fine in EG so I don't understand your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757531#M39204</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-27T21:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757533#M39205</link>
      <description>&lt;P&gt;I am looking for a way to do this in query builder instead in EG as I do not want to create a program code for this, which is an extra step always. If there is a way to build same logic in query builder I would love to learn that.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757533#M39205</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T21:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757534#M39206</link>
      <description>&lt;P&gt;The Query Builder only uses SQL and it isn't as easy that way. You can add your program as a Code Node in your EG project though.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757534#M39206</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-27T21:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757536#M39207</link>
      <description>&lt;P&gt;If by "adding program as a Code Node" you mean something like in pic below then yes that is what I always do but due to the way my projects are I prefer to learn build similar concept in query builder. I make duplicate field very often when I make joins. I am willing to learn a harder way if it helps me keep my project clearer by building messy formulas in query builder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasuser_sk_0-1627421671217.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61925i2900110A63AC280E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasuser_sk_0-1627421671217.png" alt="sasuser_sk_0-1627421671217.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 21:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757536#M39207</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T21:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757540#M39208</link>
      <description>What are you ultimately doing with the duplicates? If you're excluding them the SORT task may be an option. Or you can exclude/identify them via SORT and then merge that result with Query Builder to identify duplicates. &lt;BR /&gt;&lt;BR /&gt;Do you have other fields that help define the order of your rows, such as a date time or order variable? If so, you can often build something in query building by identifying everything that is the same as a maximum per group via a CASE statement. &lt;BR /&gt;&lt;BR /&gt;You could use the RANK task first to rank within each ID, it will enumerate the variable so that any thing with a value over 1 will be a duplicate that you could then identify via Query Builder.</description>
      <pubDate>Tue, 27 Jul 2021 22:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757540#M39208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-27T22:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757544#M39209</link>
      <description>&lt;P&gt;Thanks Reeza. In the last I would be removing the duplicates. But after glancing over the data with dups I choose whether to keep the dup&lt;/P&gt;
&lt;P&gt;value or exclude the other dup value that is blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like both options :&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;maximum per group via a CASE statement, and&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ranking&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have tried one or the other depending on the needs of the project and find them useful but just to avoid a few extra steps I was looking to create something quicker for DUPS in query builder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But if no such concept (program Code) could be done in query builder then I'll make my peace with program code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for suggestions.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 22:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757544#M39209</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2021-07-27T22:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757548#M39210</link>
      <description>I think you should relook at the features in the SORT task/proc. If you want to retain values based on another column that's doable within dual proc sorts or a single depending on the logic.  Code is below, I'll leave it as an exercise for you to figure out how to do this in the SORT task. &lt;BR /&gt;&lt;BR /&gt;IE sort variable you want to not be blank &lt;BR /&gt;&lt;BR /&gt;*puts the missing values for the otherVariable to the bottom of the list;&lt;BR /&gt;proc sort data=have;&lt;BR /&gt;by ID descending otherVariable;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=have nodupkey;&lt;BR /&gt;by ID;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Jul 2021 22:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/757548#M39210</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-27T22:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate field in EG</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/758972#M39221</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Firstly rank by ID ( MENU TASKS/DATA / RANK) . Secondly  create file DUPS with new field Duplicate and put  ’DUPS’ where  rank_sub_id=2.&lt;BR /&gt;PROC RANK DATA = active_records&lt;BR /&gt;     TIES=MEAN&lt;BR /&gt;     OUT=WORK.RANKRanked(LABEL="Rank Analysis for WORK.active_records");&lt;BR /&gt;     BY ID;&lt;BR /&gt;     VAR SUB_ID;&lt;BR /&gt;RANKS rank_SUB_ID ;&lt;BR /&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;   CREATE TABLE WORK.DUPS AS&lt;BR /&gt;   SELECT t1.ID,&lt;BR /&gt;          t1.Category,&lt;BR /&gt;          t1.SUB_ID,&lt;BR /&gt;          /* DUPLICATE */&lt;BR /&gt;            (CASE when t1.rank_SUB_ID=2 then 'DUPS' end) AS DUPLICATE&lt;BR /&gt;      FROM WORK.RANKRanked t1;&lt;BR /&gt;QUIT;&lt;BR /&gt;Kind regards&lt;BR /&gt;Natalja&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Aug 2021 07:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Duplicate-field-in-EG/m-p/758972#M39221</guid>
      <dc:creator>NataljaK</dc:creator>
      <dc:date>2021-08-03T07:10:17Z</dc:date>
    </item>
  </channel>
</rss>

