Date: Wed, 10 Sep 2003 10:10:26 -0400
Reply-To: Frank Ivis <FIvis@CIHI.CA>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Frank Ivis <FIvis@CIHI.CA>
Subject: Re: merge
Content-Type: text/plain; charset="iso-8859-1"
For this type of problem, the simplest approach is to use TWO sets, not
merge;
data new ;
set a ;
if _n_ = 1 then set b;
run;
Regards,
Frank
-----Original Message-----
From: Groeneveld, Jim [mailto:jim.groeneveld@VITATRON.COM]
Sent: Wednesday, September 10, 2003 7:35 AM
Subject: Re: merge
Hi Fred,
Then this should be your specific solution, but remember, very specific,
valid only for one observation in B. If there are more the algorithm must be
extended.
DATA A;
INPUT X Y;
CARDS;
1 2
2 2
3 5
2 4
3 3
;
RUN;
DATA B;
Z = 6;
RUN;
DATA C;
IF _N_ EQ 1 THEN MERGE A B;
ELSE SET A (FIRSTOBS=2);
RUN;
PROC PRINT DATA=C; RUN;
Regards - Jim.
Y. (Jim) Groeneveld MSc
Biostatistician
Vitatron B.V.
Meander 1051
6825 MJ Arnhem
The Netherlands
+31/0 26 376 7365; fax 7305
Jim.Groeneveld@Vitatron.com
www.vitatron.com
-----Original Message-----
From: Frédéric Paillé [mailto:f79redo@yahoo.fr]
Sent: Wednesday, September 10, 2003 13:18
To: Groeneveld, Jim
Subject: RE: merge
Thank you Jim!
It is exactly what I wanted. I'm not a SASer and your help is very precious.
Kind regards.
Fred
"Groeneveld, Jim" <jim.groeneveld@vitatron.com> wrote:
Hi Fred,
In _this_specific_case_ a solution can given as:
DATA A;
INPUT X Y;
CARDS;
1 2
2 2
3 5
2 4
3 3
;
RUN;
DATA B;
Z = 6;
RUN;
DATA C;
IF _N_ EQ 1 THEN MERGE A B;
ELSE SET A;
RUN;
PROC PRINT DATA=C; RUN;
but if your case changes, the solution has to be adopted.
Regards - Jim.
Y. (Jim) Groeneveld MSc
Biostatistician
Vitatron B.V.
Meander 1051
6825 MJ Arnhem
The Netherlands
+31/0 26 376 7365; fax 7305
Jim.Groeneveld@Vitatron.com
www.vitatron.com
-----Original Message-----
From: Fred [mailto:F79redo@YAHOO.FR]
Sent: Wednesday, September 10, 2003 11:42
To: SAS-L@LISTSERV.UGA.EDU
Subject: merge
Hi,
I have a problem.
Could someone help me please?
I have 2 datas like these:
Data A Data B
X | Y Z------ -
1 | 2 6
2 | 2
3 | 5
2 | 4
3 | 3
With a merge, I obtain:
Data C
X | Y | Z
----------
1 | 2 | 6
2 | 2 | .
3 | 5 | .
2 | 4 | .
3 | 3 | .
But I wish:
X | Y | Z
----------
1 | 2 | 6
2 | 2 | 6
3 | 5 | 6
2 | 4 | 6
3 | 3 | 6
How can I make it?
Thank you.
Frédéric PAILLE
_____
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Testez le nouveau Yahoo! Mail <http://fr.mail.yahoo.com>