Home SAS Version Control

SAS Version Control


In order to use GIT with SAS you need to:

  1. Only save linked programs and minimize the additions of new linked files (.EGPs are rarely uploaded and may be deleted/replaced.)
  2. Enable relative file paths in Project Properties for each new SAS Project.

SAS Terminology

Before going to in-depth, here is a quick visual terminology sheet for SAS: Terminology

Project – A .EGP file containing one or more process flows. A SAS project is in many ways comparable to a repository (.EGPs can even have version control, but I’ve tried it and would not recommend).

Process Flow – A collection of programs, datasets, notes, etc. It might help to think of a process flow as a folder, where you can run programs in the entire folder at once, sequentially.

Programs – The location where code is stored. In this case the comment saying “Hello World”.

Primary Considerations

  1. SAS Projects are saved as .EGP files which are a compressed proprietary format (i.e. cannot be opened by notepad and therefore cannot take advantage of version control); however, SAS programs are .SAS files which can be edited using a text editor and version controlled.
  2. By default, SAS references files as absolute rather than relative locations.

SAS Programs inside a project can be saved out to a separate location, allowing them to be controlled by GIT.

Linked programs are shown with a small arrow in the bottom left corner of the icon as shown below:

Program stored in .EGP:

.EGP Program

Linked Program:

.SAS Program

By saving programs individually, it solves issue #1 while simultaneously causing #2. Specifically because GIT is a distributed version control system where each user mirrors the database, they could be saved in a different location. This could be remedied by requiring each individual to organize files in a specified location (e.g. C:\GITHUB\RepositoryName), but since this would need to be on a local hard disk all uncommitted changes would be lost in a laptop failure. Using a network/cloud storage option can be used by enabling a setting in SAS to use relative rather than absolute paths. By using a relative path, SAS looks up the file relative to where it is saved rather than using the complete file path.

File->Project Properties->File References->Use paths relative to the project for programs and importable files.

NOTE: This must be done for each new SAS EGP

Relative References

Disable tracking of the .EGP file

To stop tracking the .egp run the following in command prompt

git update-index --assume-unchanged "FileName.EGP"

This tells git to ignore the file-changes for the file titled FileName.EGP, but if there is an update to the file in the repository that those changes could be received.

Note you will need to change directory to the folder that has the file you want to ignore with

cd FilePath

Replacing tabs with spaces

For more precise formatting, tabs can be replaced with spaces which will display more cleanly when viewed outside of SAS Enterprise Guide. This can be done by enabling these options:

  1. Insert spaces for tabs
  2. Replace tabs with spaces on file open

    Tools -> Options -> SAS Programs -> Editor Options

This post is licensed under CC BY 4.0 by the author.

Excel Tips

SAS Basics