Tuesday, 15 May 2012

SAS data manipulation for 2 table based on one column id -



SAS data manipulation for 2 table based on one column id -

i have 2 tables followings:

table 1

data table1; input id $ value; datalines; 1 2 b 1 b 2 c 1 d 1 ;

table 2

data table2; input id $ value; datalines; 1 b 2 c 1 d 1 e 1 ;

as may observed unique id table 1 a, b, c, d. delete observations id in table2 not appear in table1.

therefore lastly observation of table2 should deleted e not in {a, b, c, d}

desired output:

1 b 2 c 1 d 1

you can proc sql:

proc sql; delete table2 not exists (select 1 table1 table1.id = table2.id);

sas

No comments:

Post a Comment