Date: Fri, 18 Feb 2000 15:42:54 GMT
Reply-To: "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "John M. Wildenthal" <jmwildenthal@MY-DEJA.COM>
Organization: Deja.com - Before you buy.
Subject: Re: conditioned merging
In article <3.0.6.32.20000217224247.007f55f0@pinus.slu.se>,
Torben Haslund <Torben.Haslund@VBIOL.SLU.SE> wrote:
> Dear SAS-Lers,
>
> I want to merge:
> data set A with B, if B but not C exists
> data set A with C, if C but not B exists
> data set A with B and C, if B and C exist.
>
> data a;
> if b and not c exist merge a b;
> if c and not b exist merge a c;
> if b and c exist merge a b c;
>
> .... but how do I do that?
You didn't mention what if neither. I will assume you just reprocess a.
UNTESTED CODE...
%MACRO condmerg(a, b, c);
MERGE &a
%IF %SYSFUNC(EXIST(&b)) %THEN &b ;
%IF %SYSFUNC(EXIST(&c)) %THEN &c ;
%STR(;) ;
%MEND;
DATA outlib.member;
%condmerg(inlib.membera, inlib.memberb, inlib.memberc);
RUN;
Sent via Deja.com http://www.deja.com/
Before you buy.
|