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
It exists already:
%put %sysget(SAS_EXECFILENAME);
Perfect! Thanks!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.