Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:38:20+00:00 2026-06-15T16:38:20+00:00

Here is a sample of my data (n>3000) that ties two numbers together: id

  • 0

Here is a sample of my data (n>3000) that ties two numbers together:

id  a       b
1   7028344 7181310
2   7030342 7030344
3   7030354 7030353
4   7030343 7030345
5   7030344 7030342
6   7030364 7008059
7   7030659 7066051
8   7030345 7030343
9   7031815 7045692
10  7032644 7102337

Now, the problem is that id=2 is a duplicate of id=5 and id=4 is a duplicate of id=8. So, when I tried to write if-then statements to map column a to column b, basically the numbers just get swapped. There are many cases like this in my full data.

So, my question is to identify the duplicate(s) and somehow delete one of the duplicates (either id=2 or id=5). And I preferably want to do this in Excel but I could work with SQL Server or SAS, too.

Thank you in advance. Please comment if my question is not clear.

What I want:

id  a       b
1   7028344 7181310
2   7030342 7030344
3   7030354 7030353
4   7030343 7030345
6   7030364 7008059
7   7030659 7066051
9   7031815 7045692
10  7032644 7102337
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:38:21+00:00Added an answer on June 15, 2026 at 4:38 pm

    All sorts of ways to do this.

    In SAS or SQL, this is simple (for SQL Server, the SQL portion should be identical or nearly so):

    data have;
    input id a b;
    datalines;
    1   7028344 7181310
    2   7030342 7030344
    3   7030354 7030353
    4   7030343 7030345
    5   7030344 7030342
    6   7030364 7008059
    7   7030659 7066051
    8   7030345 7030343
    9   7031815 7045692
    10  7032644 7102337
    ;;;;
    run;
    
    proc sql undopolicy=none;
    delete from have H where exists (
      select 1 from have V where V.id < H.id
        and (V.a=H.a and V.b=H.b) or (V.a=H.b and V.b=H.a)
    );
    quit;
    

    The excel solution would require creating an additional column I believe with the concatenation of the two strings, in order (any order will do) and then a lookup to see if that is the first row with that value or not. I don’t think you can do it without creating an additional column (or using VBA, which if you can use that will have a fairly simple solution as well).

    Edit:
    Actually, the excel solution IS possible without creating a new column (well, you need to put this formula somewhere, but without ANOTHER additional column).

    =IF(OR(AND(COUNTIF(B$1:B1,B2),COUNTIF(C$1:C1,C2)),AND(COUNTIF(B$1:B1,C2),COUNTIF(C$1:C1,B2))),"DUPLICATE","")
    

    Assuming ID is in A, B and C contain the values (and there is no header row). That formula goes in the second row (ie, B2/C2 values) and then is extended to further rows (so row 36 will have the arrays be B1:B35 and C1:C35 etc.). That puts DUPLICATE in the rows which are duplicates of something above and blank in rows that are unique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Data: Here is sample table(TableA) data ID StartTime EndTime 1 2012-03-22 06:00:00.000 2012-03-22 06:30:00.000
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
Here is the sample data for test table I have [childId] [parentId] [present] 1
I wrote a symfony task to fill a database of sample data. Here's a
Here's a sample column of my data frame, RR is a header : RR
Here is the sample code, which produces interesting output: > gg<-data.frame(x=c(a,b),y=as.integer(c(1000,100000))) > gg x
I am trying to sample a subset from data with replacement and here I
Here is a sample data set ----------------------------------------------------------------------------------------- id nameid name score diff include quantity
I have some html stored in a table. here is some sample data &lt;p&gt;&lt;span
i am getting product price in multiple currency. here is a sample data CurrencyName

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.