| Date: | Mon, 4 May 2009 03:41:45 -0700 |
| Reply-To: | RolandRB <rolandberry@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | RolandRB <rolandberry@HOTMAIL.COM> |
| Organization: | http://groups.google.com |
| Subject: | Re: how to achieve the required output ? |
|
| Content-Type: | text/plain; charset=ISO-8859-1 |
On 4 Mai, 09:06, pinu <amarmundan...@gmail.com> wrote:
> Hi I have 2 datasets called Dsn1 and Dsn2.
> data Dsn1;
> input id num;
> datalines;
> 1 10
> 2 20
> 3 90
> 3 40
> 4 110
> ;
> data Dsn2;
> input id num;
> datalines;
> 1 80
> 3 90
> 4 110
> 5 120
> 7 140
> ;
> Now I want the required output as:
> Id Num
> 1 80
> 5 120
> 7 140
> ;
> The output contains all the records from second dataset(i.e. Dsn2)
> which are not in first dataset(i.e Dsn1). Also it does not contain
> common rows in both tables.
> What type of join is this? Does it have any name ?
32 data Dsn1;
33 input id num;
34 datalines;
NOTE: The data set WORK.DSN1 has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
40 ;
41 data Dsn2;
42 input id num;
43 datalines;
NOTE: The data set WORK.DSN2 has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
49 ;
50
51 proc sort data=Dsn1;
52 by id num;
53 run;
NOTE: There were 5 observations read from the data set WORK.DSN1.
NOTE: The data set WORK.DSN1 has 5 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.06 seconds
cpu time 0.00 seconds
54
55 data Dsn3;
56 merge Dsn1(in=_1) Dsn2(in=_2);
57 by id num;
58 if _2 and not _1;
59 run;
NOTE: There were 5 observations read from the data set WORK.DSN1.
NOTE: There were 5 observations read from the data set WORK.DSN2.
NOTE: The data set WORK.DSN3 has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
60
61
62 data _null_;
63 set Dsn3;
64 put (_all_) (=);
65 run;
id=1 num=80
id=5 num=120
id=7 num=140
NOTE: There were 3 observations read from the data set WORK.DSN3.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
|