08-28-2017 10:04 PM
Is it possible to extract the directory information based on where the SAS code is saved?
My current process is to manually define a macro for referrence. I would like to remove this manual process if the above is possible.
08-28-2017 10:11 PM
It really depends on how you are submitting the program.
If you have saved the program to a file and submitted the SAS command from the command line then the option SYSIN will have the program name. But it could be a relative name.
If you are using SAS Display Manager and have edited the file with the Enhanced Program Editor and saved it then SAS will have set an environment variable with the filename. But if you have not saved the program before submitting it or if you are using the normal Program Editor then that will not happen.
08-28-2017 10:20 PM
You need to add a lot more detail.
On this small amount, here's a guess at a solution. Use the following to get the path and then use the path in a %INCLUDE statement for your macro definition.
I'll usually design my project main program (control program) to take a main path parameter at the top, which is the path to the folder and then I use %include for several subfolders that can hold utitity macros, formats and other 'canned' code/processes I may need for a specific project.
08-29-2017 02:25 AM
will provide you the full path name of the program that is run in batch mode. At least it does so on AIX with SAS 9.4.
A full step to extract the path without the program name looks like this:
data _null_; length path path2 $200; path = getoption('sysin'); do i = 1 to countw(path,'/') - 1; path2 = cat(strip(path2),'/'!!scan(path,i,'/')); end; put path2=; run;