BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AmitRathore
Obsidian | Level 7

Dear Experts,

Is there any way to compare two SAS programs programatically. One way I know is to compare through TextPad but that is more of manually.

Br, Amit

1 ACCEPTED SOLUTION
7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, just datastep load them into datasets, then proc compare:

data base;

     length buffer $2000;

     infile "xyz.sas";

     input buffer $;

run;

...

proc compare base=base...;

run;

However, more importantly is why you want to do this.  Computer comparisons are logical, hence if there is one extra line in at line 2, then everything from that point on will not match. 

I would suggest that you are better off using version control software - its useful at any level of programming.  This is a database which holds base file and every revision to that file.  It can give you XML reports on differences etc.  Also has roll-back functionality and never loses history.

AmitRathore
Obsidian | Level 7

The reason of comparing program is that I need to migrate some SAS programs from SDD3.5(windows) to SDD4.5(unix). And due to this I have to make same changes in the program like changes backward slash ('\') to forward slash ('/'). After making changes I need to make sure that anything else is not changed accidently.

Br,Amit

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, you can use the compare above, but your better off using a text compare such as diff which KurtBremser has provided.  You can then use that output as part of the documentation of the migration program.

Ksharp
Super User

There are a couple of tools to compare two file . Like  WinMerge

WaltSmith
Fluorite | Level 6

Also useful is the freely available tkdiff that gives a visual, side by side comparison of programs (Unix). On a Windows platform, the PSP editor has a very similar text difference tool that does a side by side comparison.

sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10

The idea of comparing two SAS programs as-is could be flawed, depending on the SAS environment where invoked, and also considering if/how SAS AUTOCALL MACROs or MACRO statements (old SAS 79 style - ex:  MACRO _BOO  BLAH BLAH BLAH % ) may be exploited (that being embedded code references where you would only see %xxxxxxx;  (disclaimer-invoked: oversimplified example) in the main SAS code-piece being analyzed.

Also depending on the SAS process / code complexity, there may be path-conditions influencing just how much of the code is executed, such as a passed SYSPARM or incoming %LET macro variables.

Scott Barry

SBBWorks, Inc.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 10039 views
  • 8 likes
  • 6 in conversation