SAS Enterprise Guide sets values for several useful SAS macro variables when it connects to a SAS session, including one macro variable, &_CLIENTPROJECTPATH, that contains the name and path of the current SAS Enterprise Guide project file.
(To learn about this and other macro variables that SAS Enterprise Guide assigns, look in Help->SAS Enterprise Guide help, and search the Index for "macro variables".)
If your SAS program knows the path of your project file, then you can use that information to make your project more "portable", and reference data resources using paths that are relative to the project location, instead of having to hard-code absolute paths into your program.
For example, I've been working with some data from DonorsChoose.org, and I've captured that work in a project file. After saving the project, I can easily get the name of the project file by checking the value of &_CLIENTPROJECTPATH:
15 %put &_clientprojectpath; 'C:\DataSources\DonorsChoose\DonorsChoose.egp'
If you can get the full path of the project file, then you can build that information into a SAS program so that as you move the project file and its "assets" (such as data), you don't need to make changes to the project to accommodate a new project folder "home". Here is the bit of code that takes the project file location and distills a path from it, and then uses it to assign a path-based SAS library.
/* a bit of code to detect the local project path */ /* NOTE: &_CLIENTPROJECTPATH is set only if you saved the project already! */ %let localProjectPath = %sysfunc(substr(%sysfunc(dequote(&_CLIENTPROJECTPATH)), 1, %sysfunc(findc(%sysfunc(dequote(&_CLIENTPROJECTPATH)), %str(/), -255 )))); libname DC "&localProjectPath";
Here's the output:
21 libname DC "&localProjectPath"; NOTE: Libref DC was successfully assigned as follows: Engine: V9 Physical Name: C:\DataSources\DonorsChoose
This allows me to keep the project together with the data that it consumes and creates. And I can easily share the project and data with a colleague, who can store it in a different folder on his/her machine, and it should work just the same without any changes.