select from full sample all the obs except those in subsample A with sql

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

select from full sample all the obs except those in subsample A with sql

Dear all,

 

How could I select all the other observations from the full sample except all those observations in subsapmle A with proc sql?

 

Thanks a lot!


Accepted Solutions
Solution
‎08-21-2016 04:46 AM
Super User
Posts: 3,233

Re: select from full sample all the obs except those in subsample A with sql

proc sql;
 create table Sample_Remaining as
 select *
 from Full_Sample
 where Row_ID not in (select Row_ID from Sub_Sample)
 ;
quit;

This assumes you have a column called Row_ID that uniquely identifies each row in your full sample data. If you don't have such a column you can easily add one yourself.

View solution in original post


All Replies
Solution
‎08-21-2016 04:46 AM
Super User
Posts: 3,233

Re: select from full sample all the obs except those in subsample A with sql

proc sql;
 create table Sample_Remaining as
 select *
 from Full_Sample
 where Row_ID not in (select Row_ID from Sub_Sample)
 ;
quit;

This assumes you have a column called Row_ID that uniquely identifies each row in your full sample data. If you don't have such a column you can easily add one yourself.

Occasional Contributor
Posts: 17

Re: select from full sample all the obs except those in subsample A with sql

Thank you so much SASKiwi, you're so helpful!
☑ This topic is solved.

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

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