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
In UNIX, use the diff (diff utility - Wikipedia, the free encyclopedia) command. It was specifically written for this purpose.
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.
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
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.
In UNIX, use the diff (diff utility - Wikipedia, the free encyclopedia) command. It was specifically written for this purpose.
There are a couple of tools to compare two file . Like WinMerge
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.