Desktop productivity for business analysts and programmers

Code comparison in EG 7.1

Reply
Super Contributor
Posts: 434

Code comparison in EG 7.1

How to compare two SAS codes in SAS EG 7.1?

PROC Star
Posts: 1,146

Re: Code comparison in EG 7.1

Could you expand on this a bit? It's not clear what you're trying to do.

Tom

Super Contributor
Posts: 434

Re: Code comparison in EG 7.1

I've two similar SAS programs but they seem to have somo differences between them. Since it is long program it will be little difficult to do a manual comparison.

So how this can be achieved in SAS EG like we do a code comparison in text editor like Ultra Edit?

Super User
Posts: 7,465

Re: Code comparison in EG 7.1

Seems like your best option will be to save the programs as .sas files and use an external tool like ultraedit (or diff on UNIX) to do the compare.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 1,294

Re: Code comparison in EG 7.1

From this blog post from Chris H., EG 7.1 includes the ability to diff files, as one part of real version control it introduces (via GIT).  So looks to me like you are in luck (I'm not on 7.1 yet, so haven't tested.  Guess I'm not in luck. : )

http://blogs.sas.com/content/sasdummy/2014/10/12/eg-71-new-programmer-features/

SAS Employee
Posts: 54

Re: Code comparison in EG 7.1

There is also information about the ability to compare programs in the SAS Enterprise Guide 7.1 help.  This ability is part of the new program history feature.  You can use your program history to compare two different committed versions of a program, and you can compare a committed version of the program to the code that is currently in the program editor.

In the table of contents, expand "Working with Programs" and then "Understanding program history", or search for "program history".

Thanks,

Jennifer

Super Contributor
Posts: 434

Re: Code comparison in EG 7.1

Thanks for the reply. It is really helpful.

However I couldn't figure out why 'History' on the program toolbar is disable for me.

I've the programs (Client.sas and Client_updated.sas) saved in UNIX server under the folder called /data.

Super User
Posts: 7,465

Re: Code comparison in EG 7.1

The compare function within EG works only if you have already used the internal version control system for the SAS code within the project.

In your situation, I would start with using

diff /data/Client.sas /data/Client_updated.sas

from the commandline on the UNIX server and look at the output. It is a bit cryptic, but it provides all the answers. (info diff)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
SAS Employee
Posts: 54

Re: Code comparison in EG 7.1

Before you can use the program history feature to commit program changes and compare different versions of a program, your programs need to either be embedded in your project or stored in a Git repository.  There is information about this in the program history section of the help:  I'd recommend the topics entitled "Committing your program changes"  and "Understanding embedded programs."

I hope that helps!!

Thanks,

Jennifer

PROC Star
Posts: 1,294

Re: Code comparison in EG 7.1

Hi Jennifer,

On that note, is there any chance a future EG version might allow .sas files that are linked to an EG project (rather than embedded) to use the EG project file local GIT repository (if that is the right language)?

I may be an oddity, but as I've been working more with EG these past couple years, I've become a fan of EG projects, but I store all of my .sas code on the server and have only links from the project file to the .sas files.

I don't know enough about the architecture of EG (or GIT) to know if there is hope that a future iteration of this new version control approach could work with linked .sas code (and perhaps other linked files...).

Thanks,

--Q.

SAS Super FREQ
Posts: 307

Re: Code comparison in EG 7.1

Regarding Quentin's question...  external .sas files (referenced in EG projects via file system or UNC paths) can be stored in external Git repositories.  In this case, EG's Program History features (commit, view history, compare, revert, etc.) are available and execute against the external Git repository.  (Whereas, embedded programs (in EG project) are tracked in the embedded Git repository (also in EG project).)

However, the Program History feature doesn't really support .sas files referenced from the server (Server's Files location).  The reason...  even if the file was stored in a Git repository on the server, EG would not typically have shell access to the Git repository to issue Git commands.  Nor would we want to try to track changes in the "local" Git repo (embedded in the EG project), because it would only track changes to the file made from within that project.  So, if you wish to use the Program History feature with externally referenced .sas files, we recommend referencing them from an external (locally cloned) Git repository (accessible to your file system).

Casey

SAS Super FREQ
Posts: 307

Re: Code comparison in EG 7.1

To compare two programs in EG 7.1, multi-select (Ctrl+Click) the two programs in the Project Tree or Process Flow, then right-click either of the two programs, and select the Compare context menu item.

Note: This comparison feature requires a one-time installation and specification of a 3rd-party file comparison tool (I like WinMerge) in EG's Tools->Options->File Comparison.

The Program History feature provides additional versioning capabilities.  For more information on the Program History feature new to EG 7.1, see this paper:

http://support.sas.com/resources/papers/proceedings14/SAS179-2014.pdf

Super Contributor
Posts: 434

Re: Code comparison in EG 7.1

I did multi-select (Ctrl+Click) the two programs in the Project Tree and I got the warning as follows as soon I select 'Compare'.

'An custom file comparison tool must be configured to complete this action'.

You did mention  about the installation of 3rd party file comparison tool to enable this feature. But I'm not sure to have this done.

Super User
Posts: 7,465

Re: Code comparison in EG 7.1

As Casey already suggested, I also recommend WinMerge. If you don't have admin permissions on your PC, have your admin download and install it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 434

Re: Code comparison in EG 7.1

may I request you to tell me, how admin will connect (or set up the interface between EG and WinMerge) WinMerge in SAS EG after the installation of WinMerge?

Ask a Question
Discussion stats
  • 17 replies
  • 895 views
  • 6 likes
  • 7 in conversation