View previous topic :: View next topic
|
Author |
Message |
AJAYREDDY
New User
Joined: 17 Feb 2007 Posts: 52 Location: USA
|
|
|
|
Hi,
Is there any keyword or facility to compare 2 files in SAS and produce output based on MATCHED and UNMATCHED records ? I used this in Eazytrieve in my previous company, but in this company there is no Eazytrieve.
SAS, FILEAID, CLIST is used .
Please suggest me on some other options. I don't want to write this in COBOL |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I don't know about SAS, but if you look in the sort forum, you will se examples of what you are looking for. |
|
Back to top |
|
|
Aryang4u
New User
Joined: 21 Feb 2006 Posts: 8 Location: Los Angels, CA
|
|
|
|
In SAS you can use the Merge function. Let me know if you need programs. |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
Please post the code it can be helpful |
|
Back to top |
|
|
Aryang4u
New User
Joined: 21 Feb 2006 Posts: 8 Location: Los Angels, CA
|
|
|
|
Read two files.
suppose master & adhoc are two files. You are merging based on case id field.
match data set will give you matched records.
unmatch data set will give you unmatched records.
unmatch1 data set will give you records which are in adhoc file and not in master file.
---------------------------------------------
data match
unmatch
unmatch1;
merge master (in=inmaster)
adhoc (in=inout);
by caseid;
if inmaster and inout then output match;
else if inmaster and not inout then output unmatch;
else if inout and not inmaster then output unmatch1;
run;
-------------------------------------------- |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Continuing with Aryan's code:
1. An earlier DATA step must read each flat file and convert to a SAS dataset.
2. If you forget the "BY CASEID;" line, it will match 1-1 by record position, rather than giving an error/warning.
3. Files must be ordered by CASEID.
4. Most importantly - if MASTER has, say, 3 recs with a given CASEID value, and ADHOC has, say, 5 recs, then they will match 1-1 through the first three recs, then MASTER's last record (the 3rd for this value) will continue to match the remaining ADHOC recs (4th-5th with this value) |
|
Back to top |
|
|
|