DATA Step, Macro, Functions and more

How to create a macro variable containing the name of the SAS file being run

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

How to create a macro variable containing the name of the SAS file being run

I am trying to write a macro that ends up creating a dataset and I want that dataset to be named whatever the name of the SAS code is that it is run on followed by _STATS.  Basically I am trying to find out if there is a way to create a macro variable that's value is the name of the program currently being run.  This will be part of an automated process so I need it to run without manual intervention.  I was hoping there was an automatic macro variable that had this information but it does not appear to be the case.  Is there a proc or something else that would allow the file name to be stored as a macro variable?

Example:

Program name = Query123.sas

Macro variable to be created = Query123

Thanks


Accepted Solutions
Solution
‎08-13-2012 05:30 PM
Super User
Posts: 19,789

Re: How to create a macro variable containing the name of the SAS file being run

It exists already:

%put %sysget(SAS_EXECFILENAME);

http://support.sas.com/kb/24/301.html

View solution in original post


All Replies
Solution
‎08-13-2012 05:30 PM
Super User
Posts: 19,789

Re: How to create a macro variable containing the name of the SAS file being run

It exists already:

%put %sysget(SAS_EXECFILENAME);

http://support.sas.com/kb/24/301.html

Contributor
Posts: 27

Re: How to create a macro variable containing the name of the SAS file being run

Perfect! Thanks!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 179 views
  • 1 like
  • 2 in conversation