BookmarkSubscribeRSS Feed
LineMoon
Lapis Lazuli | Level 10

Hello,

 

I have a so many and big  text files .txt.

I want to compare them quickly by using sas and unix commands.

Like this:

R/R1/ab.txt

 

...

 

R/R1/wa.txt

==================

R/R2/ab.txt

 

...

 

R/R2/wa.txt

 

I want to compare the R1 and R2 files one by one R1/ab.txt with R2/ab.txt

 

Thank you for your answer

 

 

5 REPLIES 5
Reeza
Super User

Your question as it stands is vague.

 

1. What do you have to start off with?

2. Which part of this are you having difficulty with?

3. What do you want your output to look like?

LineMoon
Lapis Lazuli | Level 10

So, if i was not clear

I have a folders :R/R1 and R/R2

In R1 and R2, I have a text files : a.ext, b.txt, .... in R1 and R2

Every file in R1, I will be in R2, I want to compare R1/a.txt with R2/a.txt

 

In the output, I want to get the name of the files with a diff and the difference lines in new file : R/dif/a_dif

 

Thank you

Reeza
Super User

1. Create a listing of files from directory R1- this is relatively straightforward in a unix environment. (ls filepath or see previous posts)

2. If you're sure that you have the same in each folder you don't need to list the folders

3. Build your compare command 

4. Execute compare command and store into a file or dataset

 

What have tried so far? 

 

 

 

LinusH
Tourmaline | Level 20
Sounds like this is best performed by UNIX she'll programming - so in that sense this is not a SAS question.
What is the use case?
Data never sleeps
Kurt_Bremser
Super User

The UNIX command for comparing text files is diff. If files A and B are identical, diff A B will produce no output and return with exit code 0; differences will produce output and exit code 1, all other exit codes signal an error like file not found.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1159 views
  • 2 likes
  • 4 in conversation