Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


SAS help

SAS help

1. I need to compare 2 files which has same data in it.
To check the data for beofre and after runs.
I have 2 files:
File1 before run
File2 after run
both have same columns and i need to write SAS code to comapre and find out whether there are mismatches in the 2 files.

How many are macthing and how many not matching and how many mismatches.
Can anyone help me??

RE: SAS help


Considering the files you are talking about are flat files; I can give you a hint.
Follow the steps below,

1. Create a SAS dataset say beforeRun; by reading the complete single line into one variable (say txt_1) and create anohter varaible called obs_no which will have value of observation number into it i.e. _n_
2. Create another dataset say, afterRun by follwoing the same process steated above can create the varaibles (say txt_2) and obs_no.
(Remember you have read full record into single vairable; accordingly you need to specify the length of the variables)
3. create merged dataset of both of the above dataset, use have use the obs_no vairable as key for merging, the code will look like below

data merged_ds;
merge beforeRun after_Run;
by obs_no;

4. Now you can compare the texts in txt_1 and txt_2 variables as below and create another dataset which will enlist the differences if any in those two files.

data differ;
set merged_ds;
if strip(txt_1) ne strip(txt_2) then output;


Hope this will help you.


RE: SAS help

Worth checking out Proc Compare. I've used it a couple of times to check and it's a little unwieldy, but can simply compare ever value in ever record between the 2 datasets.

Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close