BookmarkSubscribeRSS Feed
AlexBrink
Calcite | Level 5
Hi all

I hope somebody can help me.

Is there a way to obtain the current SAS program path and filename from within a SAS session. When batch submitting, this is stored in the SYSIN option, but I was hoping there is a way to find this when in SAS itself (that is, not batch submitting a program.)

Thanks.
2 REPLIES 2
Dave_SAS
SAS Employee
In SAS 9, there is a new environment variable for the Enhanced Editor named SAS_EXECFILENAME, then you can retrieve the name of the current program by issuing this statement:

%put The current program is %sysget(SAS_EXECFILENAME);

There is also an environment variable for the Enhanced Editor called SAS_EXECFILEPATH that contains the full path of the submitted program or catalog entry. The full path includes the folder and the filename.

%put The current path is %sysget(SAS_EXECFILEPATH);
LawrenceHW
Quartz | Level 8
Dave,

It's good that SAS can finally pick-up the program it's executing at run-time interactively.

The problem is, these environment variables don't exist when the program is being batch-submitted.

Just a note to anyone using these environment variables that you need to be careful which SAS environment you're using them in.

You can check whether the program is being executed interactively (checking whether SYSPROCESSNAME = DMS PROCESS) or in batch mode.

Cheers,
Lawrence

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 2 replies
  • 1486 views
  • 0 likes
  • 3 in conversation