LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 10 Nov 2005 15:10:32 -0500
Reply-To:     SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM>
Subject:      Re: Dicrepancy between two tables-Verification
Comments: To: Arthur Tabachneck <art297@NETSCAPE.NET>

Hi Art,

Thank you for your reply.

I have used the file 'mrtg_hst' instead of t2. I just copied from something else that is the reason it is showing 'mrtg_hst' instead of t2. (:-

The code you offered me is perfectly okay with my problem except that, I don't have to rename the variable ln. Because all I need is to find the data discrepancy between t1 and t2 tables for variables x (which is in t1) and y (which is in t2). So the third condition checks the records that match with each other BASED ON VARIABLE "ID". But there would be some observations which might not have the same values for columns x (in t1) and y(in t2). So for those records, I am trying to find any observations that are in t1 and not in t2 (or vice versa)for columns x and y.

I think I didn't confuse you. right?

Thanks,

Chandra, ------------------------------------------------------ Unless I'm missing something, no, I don't think it would work.

First, while your example has files t1 and t2, you end up merging 't1' with a file called 'mrtg_hst'.

Second, if the sample code I originally offered doesn't address the problem, then I simply don't understand what the problem actually is.

Your logic creates a file, called discrepancytable, containing records which meet one of three conditions: (1) records present in t1 that don't exist in t2; (2)records present in t2 that don't exist in t1;

(up to there I'm okay, but not with the third step) (3)if a record exists in both files only output it if it doesn't exist in both files. I can't see how any records can be output by the third step.

Art ------- On Thu, 10 Nov 2005 09:26:25 -0500, SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM> wrote:

>Art, > >I am trying to compare the column x in table t1 with another column y in >table t2. That is the reason I haven't renamed column "ln". But in my >output, I will have to display id, x, y, and ln columns corresponding to >those observations that didn't match. > >Don't you think my code will work for my scenario? > > >------------ >"SUBSCRIBE SAS-L Chandra Gadde" <ddraj2015@GMAIL.COM> wrote in message >news:200511100348.jAA1m9Wu002426@malibu.cc.uga.edu... >> Hi All, >> >> I have two tables namely t1 and t2. t1 has 3 variables namely id, x, ln. >> t2 has 3 variables namely id, y, ln. >> ------------------------------------ >> data t1; >> input id x $ ln; >> cards; >> 11 a 111 >> 33 aaa 333 >> 22 aa 222 >> 44 aaaa 444 >> 48 adeil 344 >> 55 faide 123 >> 89 feilsa 378 >> 66 fade 667 >> ; >> run; >> >> data t2; >> input id y $ ln; >> cards; >> 55 faide 123 >> 44 aaaa 444 >> 33 aaa 333 >> 22 aa 222 >> 66 fad 663 >> 97 adil 345 >> 67 ilao 387 >> 55 gyth 456 >> 11 a 111 >> ; >> run; >> -------------------------------- >> >> I am trying to find the disrepancies between two tables. >> >> Here is my code. >> ---------------------------------- >> proc sort data = t1; >> by id; >> run; >> proc sort data = t2; >> by id; >> run; >> >> data discrepancytable; >> merge t1 (in = a) mrtg_hst (in = b); >> by id; >> >> if a=1 and b=0 then output discrepancytable; >> else >> if a=0 and b=1 then output discrepancytable; >> else >> if a = 1 and b = 1 then >> do; >> if a ne b then output discrepancytable; >> end; >> run; >> ------------------------------------- >> >> Here is the output for that code. >> >> Obs id ln a b >> >> 1 48 344 adeil >> 2 55 456 faide gyth >> 3 66 663 fade fad >> 4 67 387 ilao >> 5 89 378 feilsa >> 6 97 345 adil >> >> >> I am sure this is correct. I would be very happy if you could please >> correct me. Actually I have around 100,00 observations are there in >> reality. This is just a sample data I used to test my code. >> >> Thanks,


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