<?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 ID Comparison in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636351#M35759</link>
    <description>&lt;P&gt;Hi: I am a new SAS EG user and struggling here.&lt;/P&gt;&lt;P&gt;I want to compare ID from row 2 to ID in row 1 for identifying duplicates purposes and c=some other comparison needs. For example:&lt;/P&gt;&lt;P&gt;case when&lt;STRONG&gt;(id = prior(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;&lt;P&gt;case when&lt;STRONG&gt;(id = next(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here prior and next are comparing the id field in row 1 and in row 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please make suggestions?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Mar 2020 20:01:17 GMT</pubDate>
    <dc:creator>sasuser_sk</dc:creator>
    <dc:date>2020-03-31T20:01:17Z</dc:date>
    <item>
      <title>ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636351#M35759</link>
      <description>&lt;P&gt;Hi: I am a new SAS EG user and struggling here.&lt;/P&gt;&lt;P&gt;I want to compare ID from row 2 to ID in row 1 for identifying duplicates purposes and c=some other comparison needs. For example:&lt;/P&gt;&lt;P&gt;case when&lt;STRONG&gt;(id = prior(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;&lt;P&gt;case when&lt;STRONG&gt;(id = next(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here prior and next are comparing the id field in row 1 and in row 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please make suggestions?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636351#M35759</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T20:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636352#M35760</link>
      <description>&lt;P&gt;You say that this is for identifying duplicates. In that case, there are better ways than to manually compare each id with the id from the previous row. What does your data look like? And what does your desired result look like?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636352#M35760</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-03-31T20:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636354#M35762</link>
      <description>Thanks draycut. My desired result would be to create another column that would let me put filter on it for further analysis. I am aware of the method to identify duplicates by:&lt;BR /&gt;Tasks....&amp;gt;Data...&amp;gt;Sort data and then generating a different dataset that has duplicates in it.&lt;BR /&gt;&lt;BR /&gt;I want to keep my existing data set and make a new field that compares the id field.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Tue, 31 Mar 2020 20:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636354#M35762</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T20:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636358#M35763</link>
      <description>&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;Thanks draycut. My desired result would be to create another column that would let me put filter on it for further analysis. I am aware of the method to identify duplicates by:&lt;BR /&gt;Tasks....&amp;gt;Data...&amp;gt;Sort data and then generating a different dataset that has duplicates in it.&lt;BR /&gt;&lt;BR /&gt;I want to keep my existing data set and make a new field that compares the id field.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Adding a new field to your data will create a new data set. You would replace it. It might have the same name but it would not be your "existing data set".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; meant was show use an example of your current data. It doesn't have to be your data but look like it. Then show what the resulting data set with the added column would look like. Best would be to include the example data as data step code. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The logic for the created field would also help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your data currently sorted in the order that it needs to be processed?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be two different approaches, depending on your data. The RETAIN function to create a variable like "PriorID" to keep the value from the last record, or the LAG function which can reference the values of a variable in previous observations. Caution: this frequently does not work like you may expect if you use IF and LAG in the same statement.&lt;/P&gt;
&lt;P&gt;A simple example of Retain:&lt;/P&gt;
&lt;PRE&gt;Data want;
   set have;
	retain Priorid;
	&amp;lt;code&amp;gt;
	/* warning: while processing the 
	first record PriorId is not assigned
	so be aware*/
	/* at the end of the data step
	set the PriorId to the value of the 
	current id*/
	Priorid=id;
run;&lt;/PRE&gt;
&lt;P&gt;When you create the PriorID variable you should make sure that it has the same properties such as length and type as Id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636358#M35763</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-31T20:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636359#M35764</link>
      <description>&lt;P&gt;Look at the SORT task instead and the options. It will identify duplicates or unique records. Very specifically, GROUP BY processing is a unique feature in SAS and you should leverage it. SQL/Query Builder isn't a great way to accomplish this task. A data step is another approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by id;
run;

data duplicates unique;
set have;
by;
if not (first.id and last.id) then output duplicates;
else output unique;
run;&lt;/CODE&gt;&lt;/PRE&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: I am a new SAS EG user and struggling here.&lt;/P&gt;
&lt;P&gt;I want to compare ID from row 2 to ID in row 1 for identifying duplicates purposes and c=some other comparison needs. For example:&lt;/P&gt;
&lt;P&gt;case when&lt;STRONG&gt;(id = prior(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;
&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;
&lt;P&gt;case when&lt;STRONG&gt;(id = next(id))&lt;/STRONG&gt; then "Ignore" else "Keep it"&amp;nbsp;end&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here prior and next are comparing the id field in row 1 and in row 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone please make suggestions?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you!&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, 31 Mar 2020 20:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636359#M35764</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-31T20:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636362#M35765</link>
      <description>Yes my data is sorted. here is an example. This is referring to the PRIOR concept I am wanting to use in SAS EG.&lt;BR /&gt;Client id 4578 occurs twice. For first instance it is keeping it and then on the second occurrence i want to add ignore. it is identifying duplicate for me as well. Two purposes.&lt;BR /&gt;&lt;BR /&gt;client id NEW FIELD I WANT TO CREATE&lt;BR /&gt;2376 KEEP&lt;BR /&gt;2489 KEEP&lt;BR /&gt;4578 KEEP&lt;BR /&gt;4578 IGNORE&lt;BR /&gt;5478 KEEP&lt;BR /&gt;5784 KEEP&lt;BR /&gt;5784 IGNORE&lt;BR /&gt;5784 IGNORE&lt;BR /&gt;7069 KEEP&lt;BR /&gt;7069 IGNORE&lt;BR /&gt;567834 KEEP&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636362#M35765</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T20:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636363#M35766</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
if first.id then status='Keep';
else status='Ignore';
run;&lt;/CODE&gt;&lt;/PRE&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;Yes my data is sorted. here is an example. This is referring to the PRIOR concept I am wanting to use in SAS EG.&lt;BR /&gt;Client id 4578 occurs twice. For first instance it is keeping it and then on the second occurrence i want to add ignore. it is identifying duplicate for me as well. Two purposes.&lt;BR /&gt;&lt;BR /&gt;client id NEW FIELD I WANT TO CREATE&lt;BR /&gt;2376 KEEP&lt;BR /&gt;2489 KEEP&lt;BR /&gt;4578 KEEP&lt;BR /&gt;4578 IGNORE&lt;BR /&gt;5478 KEEP&lt;BR /&gt;5784 KEEP&lt;BR /&gt;5784 IGNORE&lt;BR /&gt;5784 IGNORE&lt;BR /&gt;7069 KEEP&lt;BR /&gt;7069 IGNORE&lt;BR /&gt;567834 KEEP&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636363#M35766</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-31T20:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636364#M35767</link>
      <description>Thanks! Can this be don en query builder in SAS EG?</description>
      <pubDate>Tue, 31 Mar 2020 20:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636364#M35767</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T20:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636367#M35768</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/311117"&gt;@sasuser_sk&lt;/a&gt;&amp;nbsp; I believe the query builder generates a PROC SQL query and I am afraid the parititon -by feature is unavailable in proc sql and you may have to resort to MONOTONIC(). If query builder allows monotonic in subquery and that we could flag the MIN and others as Keep and Ignore, it's easy and possible. However, I can't confirm if that idea can be &lt;EM&gt;&lt;STRONG&gt;plugged in query builder.&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636367#M35768</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-31T20:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636370#M35769</link>
      <description>&lt;P&gt;Try a RANK task and add the ranks by groups. Then you'll have 1 for the first and a number greater than one for each other record.&amp;nbsp;&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;Thanks! Can this be don en query builder in SAS EG?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 21:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636370#M35769</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-03-31T21:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636392#M35770</link>
      <description>&lt;P&gt;What I meant was&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *,ifc(min(rn)=rn,'KEEP','IGNORE') as new_variable
from
(select *,monotonic() as rn from have)
group by clientid
order by rn;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Mar 2020 21:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636392#M35770</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-31T21:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636396#M35771</link>
      <description>THANK YOU! I'll give it a try.</description>
      <pubDate>Tue, 31 Mar 2020 22:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636396#M35771</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T22:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: ID Comparison</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636398#M35772</link>
      <description>&lt;P&gt;Thank you everyone for your suggestions.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 22:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/ID-Comparison/m-p/636398#M35772</guid>
      <dc:creator>sasuser_sk</dc:creator>
      <dc:date>2020-03-31T22:25:53Z</dc:date>
    </item>
  </channel>
</rss>

