View previous topic :: View next topic |
Author |
Message |
sanjayr321 Beginner
Joined: 25 Sep 2006 Posts: 28 Topics: 15
|
Posted: Mon Aug 09, 2010 1:57 am Post subject: SAS Compare |
|
|
Iam running SAS in Enterprise guide 4.
Just want to understand how SAS compare works in the below scenario.
I have two sas datasets with 3 columns
File A
Code: |
ENO ENAME FUND1
123 ABC 5000
234 CDE 3000
456 FGH 0
|
File B
Code: |
ENO ENAME FUND1
123 ABC 5000
234 CDE 3000
456 FGH .
|
I ran the PROC compare with above two datasets using the code.
Code: |
proc compare base=FileA compare=FileB printall;
title 'Comparsion report';
run;
|
As expected, I got the third obs as unequal and first two as equal.
Again I ran the simple code which creates the file B with
"OPTIONS MISSING = '0'; to replace the '.' with '0'
Code: |
I get File B as output
123 ABC 5000
234 CDE 3000
456 FGH 0
|
I ran the PROC compare again with two sas datasets, ie., File A and new File B.
Still the third obs shows as unequal.
Can you please explain how the SAS internally compare values.
Is the two zeroes are read differently in SAS.
Is there way to overcome this issue. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12370 Topics: 75 Location: San Jose
|
Posted: Mon Aug 09, 2010 10:06 am Post subject: |
|
|
sanjayr321,
How is ENO and FUND1 is defined?
Kolusu |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
Posted: Mon Aug 09, 2010 2:04 pm Post subject: |
|
|
sanjayr321,
Check "MISSING STATEMENT" and "MISSING OPTION" in this link - http://www2.sas.com/proceedings/forum2008/082-2008.pdf
According to this document - Quote: | The MISSING option allows you to change the character displayed when missing numeric data is encountered. |
So you still get same result for compare because it is still missing (not 0).
If you want to change it to zero then probably you need to update the dataset, maybe like - Code: | if missing(fund1) then fund1 = 0; |
_________________ Regards,
Diba |
|
Back to top |
|
|
sanjayr321 Beginner
Joined: 25 Sep 2006 Posts: 28 Topics: 15
|
Posted: Mon Aug 09, 2010 6:44 pm Post subject: |
|
|
Kolusu,
ENO and FUND1 are defined as numeric.
Dibakar,
Thanks, I am experiencing the same issue for more of number fields, if I want to
update each fields it will make the program lengthy and messy.
Is there any other options which we can declare universally. |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Mon Aug 09, 2010 8:05 pm Post subject: |
|
|
Quote: |
if I want to update each fields it will make the program lengthy and messy.
| Longer (more code) most likely, but that is no reason for the code to be messy. . . _________________ All the best,
di |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 699 Topics: 63 Location: USA
|
Posted: Wed Aug 11, 2010 5:02 pm Post subject: |
|
|
Quote: |
Thanks, I am experiencing the same issue for more of number fields, if I want to
update each fields it will make the program lengthy and messy.
|
Check if COMPARE with NOMISS option makes any difference -
Code: | proc compare base=FileA compare=FileB printall NOMISS; |
_________________ Regards,
Diba |
|
Back to top |
|
|
|
|