Date: Thu, 10 Feb 2000 01:46:03 GMT
Reply-To: sashole@mediaone.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject: Re: FW: many to many merge w/o retain
Content-Type: text/plain; format=flowed
Rob,
I beg your forgiveness for trying to impersonate Paul in such a despicable,
awkward manner. I REALLY meant
data c (keep=id var1 var2);
array v ( 0:1 ) $2 var1-var2;
array z (0:9, 0:1, 1:9) $2 _temporary_;
array c (0:9, 0:1 ) _temporary_;
set a b (in=b) end=end;
c(id, b) ++ 1;
z(id, b, c(id,b)) = v(b);
if end then do id=0 to 9;
s = max(c(id, 0),c(id, 1), 0);
if s then do k=1 to s;
v(0) = z(id, 0, k);
v(1) = z(id, 1, k);
output;
end;
end;
run;
but assumed, apparently erroneously, that you did not mind sorting. No
hashing, sorry...
Kind regards,
===================
Paul M. Dorfman
Jacksonville, FL
===================
Robert Workman wrote:
>
>This can't be the REAL Paul Dorfman. There are no super cool arrays >and
>hashing algorithms in this datastep! (g)
> > -----Original Message-----
> > From: Paul Dorfman [SMTP:paul_dorfman@HOTMAIL.COM]
> > Sent: Wednesday, February 09, 2000 2:32 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: many to many merge w/o retain
> >
> > Robert,
> >
> > Then set them to missing!
> >
> > data c;
> > var1 = ' '; var2 = ' ';
> > merge a b;
> > by id;
> > run;
> >
> > Kind regards,
> > ==================
> > Paul M. Dorfman
> > Jacksonville, FL
> > ==================
> >
> > >From: "Workman, Robert" <rworkman@CARBOMEDICS.COM>
> > >Reply-To: "Workman, Robert" <rworkman@CARBOMEDICS.COM>
> > >To: SAS-L@LISTSERV.UGA.EDU
> > >Subject: many to many merge w/o retain
> > >Date: Wed, 9 Feb 2000 14:07:18 -0600
> > >
> > >I'm having trouble with a many to many merge. I want to merge two
> > datasets
> > >together by an id field. Both have variables that are not common
>between
> > >them. How do I merge them together and not have the values retained
>for
> > >those variables not common in both datasets? Instead I want the values
> > set
> > >to missing.
> > >
> > >Thanks,
> > >
> > >Rob Workman
> > >
> > >Here's an example:
> > >
> > >data a;
> > >input id var1 $;
> > >cards;
> > >1 aa
> > >2 bb
> > >2 cc
> > >3 dd
> > >3 ee
> > >3 ff
> > >;
> > >run;
> > >data b;
> > >input id var2 $;
> > >cards;
> > >1 gg
> > >1 hh
> > >1 ii
> > >2 jj
> > >2 kk
> > >2 ll
> > >3 mm
> > >;
> > >run;
> > >
> > >Results needed:
> > >
> > >id var1 var2
> > >1 aa gg
> > >1 hh
> > >1 ii
> > >2 bb jj
> > >2 cc kk
> > >2 ll
> > >3 dd mm
> > >3 ee
> > >3 ff
> >
> > ______________________________________________________
> > Get Your Private, Free Email at http://www.hotmail.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
|