IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Keyword or facility to compare 2 files in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
AJAYREDDY

New User


Joined: 17 Feb 2007
Posts: 52
Location: USA

PostPosted: Wed Mar 07, 2007 2:35 am
Reply with quote

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. icon_sad.gif

SAS, FILEAID, CLIST is used .

Please suggest me on some other options. I don't want to write this in COBOL icon_mad.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 07, 2007 2:43 am
Reply with quote

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
View user's profile Send private message
Aryang4u

New User


Joined: 21 Feb 2006
Posts: 8
Location: Los Angels, CA

PostPosted: Wed Mar 07, 2007 11:13 am
Reply with quote

In SAS you can use the Merge function. Let me know if you need programs.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Mar 07, 2007 11:34 am
Reply with quote

Please post the code it can be helpful
Back to top
View user's profile Send private message
Aryang4u

New User


Joined: 21 Feb 2006
Posts: 8
Location: Los Angels, CA

PostPosted: Wed Mar 07, 2007 12:24 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Mar 07, 2007 8:08 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top