Hello,
we have written a piece of code in a programm that we would like to include in serveral processflows in our egp. We couldn't figure out how to do that and still be able to refine the code so that it is up to date everywhere it is included in the project.
Thanks for ypur help!
I guess EG works on Windows and connects to a server, in such case store file with the code on the machne, e.g. "/myCodes/code.sas" and in your EG project add code block with this line:
%include "/myCodes/code.sas";
Bart
Hello!
... and Welcome to the community! 🙂 What about keeping it as a separate (external) piece of code and include it in the individual processes?
--FJa
This is what we tried: we saved the code snipped as "programm.sas"-file but we can include it once in the process flow (so that the filepath is correct and the programm ist not "embedded" in the project). If we add it a second time the programm is only embedded and thus can not be changed properly.
Hi @Laura1890
How about taking @yabwon approach?
In every Process Flow, Add an embedded Program entry named "Call_External" (as an example) and have the following statement inside every embedded program
%include "<SavedExternalProgramm.sas>";
Just a thought, hope this helps
Hi @Laura1890
Depending on how/where your EG execute the code. While EG can be installed on your personal Windows machine, it can execute code in the following modes
In order to include the program multiple times in EG, Check the Tools --> Options --> SAS Programs
There are "Additional SAS code" options that might give what you are looking for
Hope this helps
Laura,
could I ask another piece of information, please? The piece of code, what does it take as input and what does it produce as output? I had a little play with EG and was asking myself, what kind of program could sensibly used several times in a flow. Perhaps its input data is altered during the flow.
--fja
It only takes tables from the database as input and creates tables on our database as output.
I would like to share what we tried and worked so far:
You can include a new program to a process flow, save it and then change the filepath to the existing program (that is already included in another project flow in the same project). In order that the filepath still works with relative paths it is necessary to save the .egp-file using "save as"... and save as a new file. This sounds weird to me, but worked so far.
So it is to be included in the same Project but in different flows ... but per flow only once?
--fja
Yes, maybe this helps with the project setup:
The programs 2/3/4/5 in Flow 2 and Flow 5 refer all to the (respectively) same .sas-file
Does this code you want to attach execute the same thing in each of your programs?
If so I would do the following:
1) create file "myScript.sas" and inside it do:
%macro wrapperForMyScript();
/* Put your code here so it will be wrapped inside a macro */
%mend wrapperForMyScript;
2) add an autoexec process calling %include (remember code is in macro now so it will compile)
3) add %wrapperForMyScript()
inside your programs in places you want your code to be executed.
Bart
@Laura1890 wrote:You can include a new program to a process flow, save it and then change the filepath to the existing program (that is already included in another project flow in the same project).
I could not reproduce that on EG 8.2. It complained, that the file was already referenced by the project ...
So EG does obviously try to prevent you from including a program mutliple times in a project. One could possibly trick EG by using OS links but then I would rather go for the %include method already mentioned in the first post by @yabwon.
--fja
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.