Home > Enterprise >  SAS - Update table variable with multiple where criteria
SAS - Update table variable with multiple where criteria

Time:01-27

Please excuse my lack of knowledge i'm very new to SAS.

I have two tables as exampled below:

T1

ID Ill_No
1 1
1 1
1 2
1 2
1 3
1 3
2 1
2 1
2 2
2 2
2 3
2 3

T2

ID Ill_No
1 1
2 3

I want to update the original table with a new variable (MATCH) where both ID and Ill_No match with the second table. Example below:

T1

ID Ill_No MATCH
1 1 Y
1 1 Y
1 2
1 2
1 3
1 3
2 1
2 1
2 2
2 2
2 3 Y
2 3 Y

What is the most efficient way to do this?

CodePudding user response:

Perhaps use a simple merge statement

data want;
merge t1(in=one) t2(in=two);
by id III_No;
if one and two then match = 'Y';
run;
ID  III_No  match
1     1       Y
1     1       Y
1     2 
1     2 
1     3 
1     3 
2     1 
2     1 
2     2 
2     2 
2     3       Y
2     3       Y
  • Related