BookmarkSubscribeRSS Feed
GrandGrue
Fluorite | Level 6

We use Git and GitLab for all our code (Python, R). In order to make more intensive use of version control for SAS code and projects that were created with Enterprise Guide, the self-written SAS code would have to be stored in external files. SEG normally saves the code in the EGP file. This means that it is hidden in a binary file and not visible to Git. Enterprise Guide offers the option of saving a code element individually externally. A relative path to the project file can be used. This option is good, but especially in large EG projects it is tedious to manually save each individual code element externally and to ensure that no code element is stored internally. For this reason, we are looking for a script or similar that can support us in this work. Has anyone already done something similar?

13 REPLIES 13
dalocja
Calcite | Level 5

To automate saving SAS code elements from Enterprise Guide to external files for better Git integration, consider using a Python or SAS script that iterates through all code nodes in the project and exports them to specified paths.

GrandGrue
Fluorite | Level 6

Thank you for this suggestion. I already had that idea too. Unfortunately, I could not find an online source that describes all the classes and functions that are necessary for this. Everything I have found so far refers to EG 4.1, which was a code base that did not yet allow referential storage in projects, for example (only came with EG 4.3). Do you know a description of the scripting library which is up to date (EG 8)?

AlanC
Barite | Level 11

EGP files are merely binary zip files. They can be unzipped and the XML extracted. Playing version control that way, however, would be dangerous. That said, try it and see how it goes. Rename the file from ex. MyFile.egp to MyFile.zip and you can explore the structure.

 

Using C#, I have unwound the ZIP files as well as the XML so I can extract out the actual SAS code. That app is on github under SaviApp. Note: the EGP XML files and how everything holds together took a lot of work to figure out. Be prepared if you want to figure it out in python..  

https://github.com/savian-net
GrandGrue
Fluorite | Level 6

Thank you very much for your support. This is my plan B if the above does not work. I have an almost finished solution with the following resource: https://github.com/cjdinger/sas-eg-automation/blob/master/vbscript/ExtractCodeAndLog.vbs
But I want to avoid this way, because changes to the code can only be mapped if the script is reliably executed before each commit.

AlanC
Barite | Level 11

Let me save you some time (hopefully). The zip file changes each version (or major version). The XSD for the XML in those files is not public (SAS devs don't need it since they can direct map to the nodes). Think of the XML as the serialized version of the object. You have to guess at the deserialization.

 

The key, for you currently, is that it changes per version. This becomes more dramatic over time. VBS is also a poor language and very much a security risk. That might not matter in your situation. 

 

You can continue to press the VBS script but getting it to work (for more than the specific version it was built for) is probably futile and is a poor platform (vbs) to boot. YMMV but that is my .02 cents.

 

 

 

 

https://github.com/savian-net
GrandGrue
Fluorite | Level 6

Yes, I see the limitations. I even already have a piece of SAS code that can open the EGP/ZIP file and extract the code elements from it.
I would prefer to have a SAS option that always saves all code elements externally. Since this does not exist, I thought the second best option is a small script that does this. Once this is done, then code changes are always made in the external files and no post-processing is needed.

AlanC
Barite | Level 11

Let me try and take a stab and how I would approach if given those circumstances. You can translate to python/your world and see if it makes sense.

 

I use C#/PowerShell so this is from that perspective.

 

I am happy to share my C# code that unwinds the EGP and put it on github. Would have to put in a bit of time to get it ready for publication but I have no objections.  

   

https://github.com/savian-net
GrandGrue
Fluorite | Level 6

Thank you for the offer. I would be very interested in your code example.

AlanC
Barite | Level 11

For now, use the command line tool that is there:

 

https://github.com/savian-net/SaviEg

 

 

https://github.com/savian-net
SASKiwi
PROC Star

With EG 8 (and some earlier versions) you can completely bypass using EGPs and exclusively save your SAS code in external text files. This is what we do and it works fine with Git / Azure DevOps which we use for all of our production work.

GrandGrue
Fluorite | Level 6

This is a valuable suggestion and we would also like to go down this route for new projects. My question concerns the approximately 1000 existing EG projects, which we would like to make more accessible for Git.
Let me illustrate my request better with screenshots (sorry that this is a German version 7.1):

  • In the project settings, I can make EG save the path only relative when a file is saved externally (screenshot 01)
    01_screenshot-egp-rel-path-proj.png
  • If I use “Save as” in a code element, the element is saved externally (very good for Git / screenshot 02)
    02_screenshot-eg-programm-speichern-unter.png
  • The small arrow symbol shows code that is stored externally and only refers to it (screenshot 03)
    03_screenshot-eg-programm-intern-extern.png

I am now looking for a script that automates these manual “Save as” steps. In other words, I want to retain the EG's own functionality and not extract the code elements from the EGP.

AlanC
Barite | Level 11

You can create a custom task using C#. EG is written in C# and it provides a means of doing this. You have to adhere to an interface and implement the parts.

 

There are examples on the SAS website and I should have an example or two on my github.  

https://github.com/savian-net
Patrick
Opal | Level 21

The Viya 4 SAS Studio git integration is imho much more streamlined. With the future in mind (it's actually already present) I'd be looking into the migration path of SAS EG to SAS Studio and the git integration capabilities of SAS Studio. 

The latest EG versions are now also compatible with SAS Viya but they don't offer the same richness in functionality. I'm especially fond of SAS Studio Flow and the growing number of SAS Studio Custom Steps available in public git repositories that one can use to build such flows.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 13 replies
  • 2880 views
  • 10 likes
  • 5 in conversation