BookmarkSubscribeRSS Feed
sirisha
Calcite | Level 5

I have two datasets:

Set A: Michael, Rahul, Dalton, Barb....................1020 observations

Set B: Disouza, Michael, Glory, Victoria, Daniel, Chip...............200 observations

Desired:

Set A: Michael, rahul, dalton, barb....................1020 observations

Set B: Disouza, Glory, Victoria, Daniel, Chip,...........200 or less observa

I would like to have unique names in set B. i.e., If names from set A are repeated in set B, I have to remove them. At the end, I need unique observations in Set B (200 or less but not more).

What I did:  I sorted the two files by name and then merged them by first name. Then I used the nodupkey and dupout to separate the repeated observations. But I couldn't create the same set B. My new set B has values from set A too.

Any kind of help would be greatly appreciated.

2 REPLIES 2
Reeza
Super User

You need to be more clear in your question.

Is your data in columns or rows?

Post a small example of what you have and what you want and any code you've tried and WHY it didn't work.

How does case affect your data? Is Rahul the same as rahul? SAS comparisons are case sensitive.

From what you have my suggestion would be a proc sql with a where not in.

proc sql;

create table want as

select * from a

where name not in (select name from table b);

quit;

You could also try a datastep merge and use something like:

data want;

merge have1 (in=a) have2(in=b);

by name;

if b and not a;

run;

sirisha
Calcite | Level 5

Reeza,

My data is in Excel sheets. Each sheet has 50 variables. Two excel sheets have just the variable name in common. Rest of the variables are company, work phone, personal phone, marrital status, so on...

And the data is not case sensitive. All names start with capital letter and continue with regular case. I am trying your code and I will return to you in about 10 min with sample dataset, if that code doesn't work.

Thank you for your prompt response

Sireesha

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 801 views
  • 0 likes
  • 2 in conversation