BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Zachary
Obsidian | Level 7

Is there a way in Enterprise Guide to write some code to call one program from another program within the same process flow? I fully understand that we can graphically link them together so that one may come before the other, but can this be done via code?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The %INCLUDE statement works when the programs are stored as files on the SAS server that's running the programs.  The %INCLUDE statement requires a fileref or file path that can be resolved from within the SAS session.

If your programs are simply embedded in the SAS Enterprise Guide project (and not saved as separate files), then you cannot programmatically reference them from other program nodes in the project.

Also, if your programs are .SAS files referenced from your local machine, but the SAS server running them (ex: SASApp) is remote, then you cannot reference the local programs from code running on that remote server.  (Exception: if you can somehow reference your local files from the remote server using a network share...)

So, how can you achieve this?  Some ideas:

  • If the code you want to reuse can be refactored into a SAS macro, then you can submit that once at the beginning of your project and invoke it throughout within other programs.  That's the classic method for reusing SAS programming logic.
  • You could use a method like the Copy Files task to copy your SAS program from a local disk to a remote SAS folder, and then %include the resulting file from that upload location.  This would allow you to maintain the program locally, and then initiate your SAS session with the latest version as your project runs.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Yes. Check out the %INCLUDE statement.

ChrisHemedinger
Community Manager

The %INCLUDE statement works when the programs are stored as files on the SAS server that's running the programs.  The %INCLUDE statement requires a fileref or file path that can be resolved from within the SAS session.

If your programs are simply embedded in the SAS Enterprise Guide project (and not saved as separate files), then you cannot programmatically reference them from other program nodes in the project.

Also, if your programs are .SAS files referenced from your local machine, but the SAS server running them (ex: SASApp) is remote, then you cannot reference the local programs from code running on that remote server.  (Exception: if you can somehow reference your local files from the remote server using a network share...)

So, how can you achieve this?  Some ideas:

  • If the code you want to reuse can be refactored into a SAS macro, then you can submit that once at the beginning of your project and invoke it throughout within other programs.  That's the classic method for reusing SAS programming logic.
  • You could use a method like the Copy Files task to copy your SAS program from a local disk to a remote SAS folder, and then %include the resulting file from that upload location.  This would allow you to maintain the program locally, and then initiate your SAS session with the latest version as your project runs.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Zachary
Obsidian | Level 7

Thank you very much. I am still very new to all of this. It seems a little counterintuitive to not have a feature of referencing files within the same project. But I especially like the suggestions you provided.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 19330 views
  • 2 likes
  • 3 in conversation