Date: Fri, 7 Apr 2000 17:12:20 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: Proc Compare
Sharavi informed me that the observations in the two data sets
correspond one-to-one. I presume however that they are not
uniquely identified. Otherwise, it seems to be a straightforward
So create unique identifiers. Let the two data sets be named OLDER
and NEWER (with NEWER carrying the values to be used in cases
where both data sets have non-missing values for a particular variable).
data older; input a b c; cards;
1.11 . 1.3
2.1 2.2 2.3
3.1 3.2 3.3
data newer; input a b d; cards;
1.12 1.2 1.4
2.1 . 2.4
3.1 3.2 3.4
data master; set older; _seq++1; run;
data transact; set newer; _seq++1; run;
data combined; update master transact; by _seq; drop _seq; run;
OBS A B C D
1 1.12 1.2 1.3 1.4
2 2.10 2.2 2.3 2.4
3 3.10 3.2 3.3 3.4
So this will work as desired even if there is not a one-to-one
correspondence between the variables in the two data sets.
It will hit the rocks if there is a numeric variable in one data
set and a character variable with the same name in the other
On Wed, 5 Apr 2000 23:19:39 -0400, Sharavi Gandham
>First let me say thanks to all of you,who responded to my earlier question
>about Formats,Thanks a lot.
>Ok, that out of the way, to my next question,
>I have two datasets which have almost the same variables,i need to compare
>them and also update them with the new values which maybe in either of the
>datasets.Like for eg:
>xxx dataset yyy dataset
>If they have same values,leave it at that.
>If they have different, update with the current one.
>If it is missing ,update with nonmissing value.
>I hope i explained my problem clearly,
>I tried doing this by first sorting each datasets by a particular
>variable,and then merging them with Proc Compare but it is such a long
>one,also it doesn't update it.Also i have to change the name of all the
>variables so that they just don't override the ones already in place.
>So i hope someone has a solution to this,
>Thanks in advance.
>Looking forward for the response.