LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (April 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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 UPDATE application.

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;

The result:

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 data set.

On Wed, 5 Apr 2000 23:19:39 -0400, Sharavi Gandham <SHARAVI@WORLDNET.ATT.NET> wrote:

>Hello All >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 >x1....222 x1.....222 >x2....333 x2.....444 >x3....missing x3.....555 >x4....666 x4.....missing >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.


Back to: Top of message | Previous page | Main SAS-L page