Date: Tue, 22 Jul 1997 17:03:24 +0500
Reply-To: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject: Re: one-to one merge
Hi,
This looks like a nice FULL JOIN from SQL.
SAS code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data f1;
input @1 n1 $1. +1 n2 $1.;
cards;
1 a
1 b
2 a
2 b
;
run;
data f2;
input @1 n1 $1. +1 n2 $1.;
cards;
1 z
1 y
2 z
2 y
;
run;
proc sql;
options ls=72 pageno=1;
title 'Full join of f1 & f2';
select a.n1, a.n2, b.n2 as n3 from f1 as a full join f2 as b
on a.n1 = b.n1
;
quit;
SAS OUTPUT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Full join of f1 & f2 1
11:01 Friday, July 18, 1997
N1 N2 N3
----------
1 b y
1 b z
1 a y
1 a z
2 b y
2 b z
2 a y
2 a z
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Does it looks OK ?
Hope it helps,
Bernard Tremblay
\\\|///
\\ - - //
( @ @ )
+------oOOo-(_)-oOOo----------+---------------------------------+
| Bernard Tremblay | |
| La Capitale | Tel: (418) 646-2401 |
| | Fax: (418) 646-5960 |
| | Int: bernard@capitale.qc.ca |
+-----------------------------+---------------------------------+
| Imaginasys enr | Res: (418) 878-4447 |
| | Int: bertrem@quebectel.com |
+---------------Oooo----------+---------------------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>From owner-sas-l@UGA.CC.UGA.EDU Tue Jul 22 16:46 EDT 1997
>>>Nntp-Posting-Host: fslo16.fsw.leidenuniv.nl
>>>Mime-Version: 1.0
>>>Content-Transfer-Encoding: 7bit
>>>Xref: paladin.american.edu comp.soft-sys.sas:41175
>>>Date: Tue, 22 Jul 1997 14:05:57 +0200
>>>From: Ed Noyons <noyons@ruls20.fsw.LeidenUniv.nl>
>>>Subject: one-to one merge
>>>To: SAS-L@UGA.CC.UGA.EDU
>>>
>>>Hi,
>>> The SAS merge function is sometimes quite tricky as you know. I wonder
>>>if there is a way to merge A and B to C:
>>>
>>>A: B:
>>>1 a 1 z
>>>1 b 1 y
>>>2 a 2 z
>>>2 b 2 y
>>>
>>>C:
>>>1 a z
>>>1 b z
>>>1 a y
>>>1 b y
>>>2 a z
>>>2 b z
>>>2 a y
>>>2 b y
>>>
>>>Ed