DATA Step, Macro, Functions and more

How do I retain only the data specific to identifiers located in another dataset?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

How do I retain only the data specific to identifiers located in another dataset?

Hi all,

I am relatively new to SAS and has been trying to sort my dataset. I have a dataset A containing the identifiers for companies I need and another dataset B containing the whole universe of companies. How do I find only the companies I need from the universe in dataset B using the identifiers in dataset A?

Thank you for any advice given.


Accepted Solutions
Solution
‎01-18-2013 01:02 AM
Super User
Super User
Posts: 7,071

Re: How do I retain only the data specific to identifiers located in another dataset?

Many ways.

Classic SAS code.

data want ;

  merge A(in=in1) B ;

  by id;

  if in1;

run;

Proc SQL

proc sql ;

create table want as select * from a left join b on a.id = b.id ;

quit;

View solution in original post


All Replies
Solution
‎01-18-2013 01:02 AM
Super User
Super User
Posts: 7,071

Re: How do I retain only the data specific to identifiers located in another dataset?

Many ways.

Classic SAS code.

data want ;

  merge A(in=in1) B ;

  by id;

  if in1;

run;

Proc SQL

proc sql ;

create table want as select * from a left join b on a.id = b.id ;

quit;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation