Question

I need to compare two text files (in different directories) to see if they are different (a binary result is fine). Given a dataset such as the one below, is this possible within a datastep?

Pathname
c:\one\text1.txt
c:\two\text1.txt
c:\one\text2.txt
c:\two\text2.txt

Alternatively, macro code would be fine! Checksum is a possibility, I need the code to run in both windows & unix.

Was it helpful?

Solution

Pass it to the command line (via a pipe fileref)

In Windows, use the 'comp' command.

In Unix, use the 'diff' command.

OTHER TIPS

Thanks to Chris J - this worked for me:

%let root=%sysfunc(pathname(work));
data;
file "&root.\x.txt";
put 'xxx';
data;
file "&root.\x2.txt";
put 'xx x';
filename x pipe "diff &root.\x.txt &root.\x2.txt ";
data;
infile x;
input x $1000.;
run;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top