Date: Mon, 3 Jul 2006 09:18:43 -0400
Reply-To: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Subject: Re: Merge fails to pick up ID?
In-Reply-To: A<200606302046.k5UIWk2s026042@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
Kitty,
As you can see by your results, changing the attributes of your id variable may not have been a good thing. You might want to explain further the original problem that prompted you to change the variable because of a format.
That being said, you need to look at the physical contents of A and newB. Most likely you may not have used exactly the same method, resulting in different values. For example, one may be left justified and the other not. do something like this:
proc print data=a (obs=100);
title "A";
var caseid;
format caseid=$char24.;
run;
proc print data=newB (obs=100);
title "B";
var caseid;
format caseid=$char24.;
run;
HTH...
clint
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
Kitty Lee
Sent: Friday, June 30, 2006 4:46 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Merge fails to pick up ID?
Hi. I have a funny situation.I have two dataset A and B and I need to
perform a simple merge by CaseID.
I did a proc contents of data A. The Caseid variable has this format
CASEID Char 24 $24. $24. CASEID
My dataset B originally has Caseid as a numeric. I did this to change the
format.
data newB (keep=caseid raw estmm);
caseid=put(caseidA, 24.);
set B(rename=caseid=caseidA);
run;
I checked the proc contents of the new dataset newB:
# Variable Type Len Format Informat
1 caseid Char 24
Then I tried to merge the two datasets.
data joinAB; merge A newB; by caseid; run;
But the merge failed. Essentially the two datasets were stacked up
instead---Dataset A has 1000 cases and Dataset newB has 300 cases. The
dataset after merge has 1300 cases.
Somehow the program thinks the caseids are different. How come?
K.