12-05-2016 03:43 PM
I have the following data
input subj Height Weight;
001 68 155
002 75 220
003 65 99
005 79 266
006 70 190
009 61 122
input subj salary;
a. I want to use Proc SQL to create a new SAS data set containing Subj (both Subj variables), Height, Weight and Salary, I know I have to rename Subj from the left data set as LeftSubj and rename Subj from the right data set as RightSubj in Proc SQL, however i'm not sure how to do this. When I do it on my own the output doesn't come out right.
12-05-2016 06:31 PM
Why not post what you've tried and we can suggest modifications?
It's good to know what didn't work with your methodology.
The SAS documentation has a list of all the different ways of combining data and code on how to accomplish each method.
12-05-2016 10:31 PM
Try below code.
proc sql; create table want as select a.subj , a.height , a.Weight , b.salary from left a inner join right b on a.subj = b.subj; quit;
Try changing key inner join to left join or right join to get desired result.
Link shared by @Reeza must read to understand the concept.