05-05-2016 09:11 AM
I am getting some issue while outer join the tables. Please help
I have 2 data set (test1) and (test2). In test1 ther is 2 columns and in test2 there is 1 column only.
Now I want to put outer join on both of the tables. I want it should display all the records from test1 and where code is not matching it should blank for code. see below is my code
input name $ code $;
proc sort data=test1;
proc sort data=test2;
merge test1 (keep=_all_ in=a)
test2 (keep =code in=b);
I want the output which is displaying in below proc sql.Please help how I can get both the code values in data step
from test1 as a left outer join test2 as b
05-05-2016 09:46 AM
Are you looking for a report or a SAS dataset? The DATA step is generating a SAS dataset and the SQL is just generating a report. If you tried to create a dataset from the SQL, you would need to rename test2.code to something else to get two 'code' columns. You could accomplish the same thing in test2 with an assignment statement (essentially duplicating test2.code with a different name).