Convert Your SAS Enterprise Guide Project into a Stored Process
A previous tip looked at converting an existing SAS® Program into an SAS Enterprise Guide (EG) project. However one of the questions raised in response to this tip was how to turn a SAS EG Project into a SAS Program.
One way of converting an EG Project into a SAS Program is by creating a Stored Process for the Process Flow within SAS EG.
However, there are a few pre-requisites for the successful conversion of an EG Process Flow into a SAS Program:
- Firstly the user must have an active connection to a metadata server, otherwise a Stored Process cannot be created.
- Secondly certain objects in the Process Flow, such as SAS Graphs, require the code to be executed first, prior to creating the Stored Process, otherwise the Stored Process will not contain the code for those objects.
- Thirdly if the Project uses Prompts, the value used for the prompt will not be embedded within the Project; however the Prompts are still required when running the Stored Process or Program.
To create a Stored Process from the SAS project, the user can either right click inside the Process Flow and select "create stored process" or right click on the Process Flow and select "Create Stored Process".
This will now open the wizard to create a Stored Process.
On page 2 of the wizard "SAS Code", all of the SAS code created for each step inside the Process Flow will now appear in the code window as below:
At this stage, the user could simply "Copy and Paste" the code from this window and paste into a new SAS program.
However, if any prompts are being used, these will need to be added to the SAS Program within Enterprise Guide, otherwise the code will error at the places where prompts are used.
Alternatively, continue with the remaining steps in the Wizard to create a Stored Process equivalent to the Process Flow.
Steps 3 through to 7 are standard steps for options when creating a Stored Process. The source code used in the Stored Process can be stored centrally onto the server which will create a .sas program file in the location you specify.
All prompts used within Tasks in the Process Flow should be automatically added in Step 5, as in the example below.
After the Stored Process wizard has been completed, the Stored Process should appear within your project, and will contain all the code that was previously used for the entire Process Flow.
Running the Stored Process will give the same output as the original Process Flow, and use the same prompts.