问题描述:

Does any one know how to insert only "new" row to the existing table with in SAS PROC SQL ?

proc sql;

create table class as

select *

from sashelp.class

where sex = 'F';

quit;

proc sql;

create table classm as

select *

from sashelp.class

where sex = 'M' or Name = 'Alice';

quit;

proc sql;

insert into class

select *

from classm ;

quit;

The insert statement does not allow me to use where statement to insert only 10 new row from classm ( without Alice )

Is there a way to go around this ? Because I'm working with big data I would like to do this with in proc sql , or data step is fine.

Thanks

网友答案:

This worked for me...

proc sql;
create table class as 
select * 
from sashelp.class 
where sex = 'F'; 
quit;

proc sql;  
create table classm as 
select * 
from sashelp.class 
where sex = 'M' or Name = 'Alice';
quit;

proc sql;
insert into class 
select * 
from classm 
where name^="John";
quit;
网友答案:

why not use the merge?

you sort your two tables by the columns who are the reference (id) and the merge the two tables with the selected keys.

相关阅读:
Top