Prev: Can specify one column when importing excel file?
Next: Need a shell script to run the SAS Jobs
From: Andy Wong on 14 May 2010 00:47 Hello all, I want to merge dataset 1 and dataset 2 by ID and SubID. Here is my example: Dataset 1 ID SubID 10 1 10 3 10 5 20 2 20 4 Dataset 2 ID SubID Emp 10 1 10 10 2 20 10 3 30 10 4 40 10 5 50 20 1 10 20 2 20 20 3 30 20 4 40 20 5 50 I want my output to look like this: ID SubID Emp 10 1 10 10 3 30 10 5 50 20 2 20 20 4 40 Thanks in advance for helping me. Andy
From: Amar Mundankar on 14 May 2010 02:28 On May 14, 12:47 am, Andy Wong <kaw...(a)gmail.com> wrote: > Hello all, > > I want to merge dataset 1 and dataset 2 by ID and SubID. > Here is my example: > > Dataset 1 > ID SubID > 10 1 > 10 3 > 10 5 > 20 2 > 20 4 > > Dataset 2 > ID SubID Emp > 10 1 10 > 10 2 20 > 10 3 30 > 10 4 40 > 10 5 50 > 20 1 10 > 20 2 20 > 20 3 30 > 20 4 40 > 20 5 50 > > I want my output to look like this: > > ID SubID Emp > 10 1 10 > 10 3 30 > 10 5 50 > 20 2 20 > 20 4 40 > > Thanks in advance for helping me. > > Andy Hi Andy, You can use the following code. data one; input ID SubID ; cards; 10 1 10 3 10 5 20 2 20 4 ; Data two; input ID SubID Emp ; cards; 10 1 10 10 2 20 10 3 30 10 4 40 10 5 50 20 1 10 20 2 20 20 3 30 20 4 40 20 5 50 ; data three; merge one(in = InOne) two; by id subid; if InOne; run; proc print data = three; run; Thanks and Regards, Amar Mundankar.
From: Andy Wong on 15 May 2010 22:27 On May 13, 11:28 pm, Amar Mundankar <amarmundan...(a)gmail.com> wrote: > On May 14, 12:47 am, Andy Wong <kaw...(a)gmail.com> wrote: > > > > > > > Hello all, > > > I want to merge dataset 1 and dataset 2 by ID and SubID. > > Here is my example: > > > Dataset 1 > > ID SubID > > 10 1 > > 10 3 > > 10 5 > > 20 2 > > 20 4 > > > Dataset 2 > > ID SubID Emp > > 10 1 10 > > 10 2 20 > > 10 3 30 > > 10 4 40 > > 10 5 50 > > 20 1 10 > > 20 2 20 > > 20 3 30 > > 20 4 40 > > 20 5 50 > > > I want my output to look like this: > > > ID SubID Emp > > 10 1 10 > > 10 3 30 > > 10 5 50 > > 20 2 20 > > 20 4 40 > > > Thanks in advance for helping me. > > > Andy > > Hi Andy, > You can use the following code. > > data one; > input ID SubID ; > cards; > 10 1 > 10 3 > 10 5 > 20 2 > 20 4 > ; > > Data two; > input ID SubID Emp ; > cards; > 10 1 10 > 10 2 20 > 10 3 30 > 10 4 40 > 10 5 50 > 20 1 10 > 20 2 20 > 20 3 30 > 20 4 40 > 20 5 50 > ; > data three; > merge one(in = InOne) two; > by id subid; > if InOne; > run; > proc print data = three; > run; > > Thanks and Regards, > Amar Mundankar.- Hide quoted text - > > - Show quoted text - Thanks!
|
Pages: 1 Prev: Can specify one column when importing excel file? Next: Need a shell script to run the SAS Jobs |