In my example, I used IDNO as an example of the variable(s) that you would use to do the join. IDNO, in my example, is a fictional variable. Instead of IDNO, use the actual variable(s) that you are using to join the tables. As I said, my response is general in nature since we don't have any sample data or expected output to work with. You don't need to attach the entire table(s), by the way. You can attach subsets of the data, or even samples with fictional data if you are concerned about privacy/confidentiality issues. Regarding 6 variables having values of 999999, you can reuse the code samples I provided to recode as many variables as needed, eg DATA together ; merge table1 (in=a rename=(var1=table1var1 var2=table1var2 var3=table1var3 . . . etc . . . )) table2 (in=b rename=(var1=table2var1 var2=table2var2 var3=table2var3 . . . . etc . . . )); by idno ; /* fictional join variable - to be replaced with your actual by variable(s) -- make sure tables are presorted */ if a and b then do ; /* change as needed to get only left side (if a) or right side (if b) or either side (if a or b), etc. */ if table1var1 = 999999 then var1 = table2var1; else var1 = table1var1 ; if table1var2 = 999999 then var2 = table2var2; else var2 = table1var2 ; if table1var3 = 999999 then var3 = table2var3; else var3 = table1var3 ; . . . . more lines . . . . output; end; run; OR in PROC SQL . . . . proc sql; create table together as select t1.idno , ( case when t1.var1 = 999999 then t2.var1 else t1.var1 end ) as var1 , ( case when t1.var2 = 999999 then t2.var2 else t1.var2 end ) as var2 , ( case when t1.var3 = 999999 then t2.var3 else t1.var3 end ) as var3 . . . . more case statements . . . from table1 as t1, table2 as t2 where t1.idno = t2.idno /* fictional join variable. Assumes you want an equijoin */ order by idno quit;
... View more