Date: Wed, 3 Dec 2008 10:19:04 -0600
Reply-To: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject: Re: Merge Many to one without repeat
In-Reply-To: <d1d69a06-a28a-4635-af65-446b7375a97b@j39g2000yqn.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
I think you can simply set all values to missing as in this example.
Any values from B would remain missing until a new obs from B is read.
Values from A are updated on each observation.
data C;
merge a(in=f1) b(in=f2);
by ID;
if f1;
output;
call missing(of _all_);
run;
On 12/3/08, Akramx <akram.chriai@gmail.com> wrote:
> Hi everybody,
> I want to do a special merge.
> I have two tables A and B:
> data A;
> input ID $ 1 Num 12.;
> datalines;
> a 24
> a 65
> a 43
> ;
> run;
>
> data B;
> input ID $ 1 color $5.;
> datalines;
> a Red
> b Green
> c White
> ;
> run;
>
> the usual merge BY ID fot these tables is :
> code:
> proc sort data=a; by ID;run;
> proc sort data=b; by ID;run;
>
> data C;
> merge a(in=f1)
> b(in=f2);
> by ID;
> if f1;
> run;
>
> result (Table C):
>
> Obs ID Num color
> 1 a 24 Red
> 2 a 65 Red
> 3 a 43 Red
>
> What I want is to merge only the first (or last) line By ID with the
> corresponding line in table B, like it's illustrated here:
> Obs ID Num color
> 1 a 24 Red
> 2 a 65
> 3 a 43
>
> I can use : if not First.ID then Color=''; but you understand that
> it'a only a sample here, and in reality I have about 90 columns...
>
> thanks for your help.
>
|