# SAS software: how to programmatically retrieve the name of the SAS program code file?

**URL:** <https://boards.straightdope.com/t/sas-software-how-to-programmatically-retrieve-the-name-of-the-sas-program-code-file/832455>\
**Category:** Factual Questions\
**Created:** [April 12, 2019, 8:02pm UTC](https://boards.straightdope.com/t/sas-software-how-to-programmatically-retrieve-the-name-of-the-sas-program-code-file/832455 "2019-04-12T20:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Napier](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Napier](https://boards.straightdope.com/u/Napier)\
**Post date:** [April 12, 2019, 8:02pm UTC](https://boards.straightdope.com/t/sas-software-how-to-programmatically-retrieve-the-name-of-the-sas-program-code-file/832455/1 "2019-04-12T20:02:52Z")

</div>

I want my SAS program to retrieve the filename associated with the SAS code I am currently running. That name is in the system somewhere – it’s displayed in the top border of the Program Editor window. It’s, what, a system macro variable? a special variable? is there a call routine? I’m not finding it.

My program creates a long report, and there are variants of the program. I want the report to include the name of the program variant that created it.

Thanks!!

---

<div class="post-metadata">

**Author:** ![naita](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/naita/32/5862_2.png) [@naita](https://boards.straightdope.com/u/naita)\
**Post date:** [April 12, 2019, 10:29pm UTC](https://boards.straightdope.com/t/sas-software-how-to-programmatically-retrieve-the-name-of-the-sas-program-code-file/832455/2 "2019-04-12T22:29:18Z")

</div>

This seems relevant. If not I blame the fact that I don’t know SAS and only felt like it should be googleable:

> **[023-2008.pdf](https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/023-2008.pdf)**
>
> 66.97 KB

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [April 13, 2019, 12:07am UTC](https://boards.straightdope.com/t/sas-software-how-to-programmatically-retrieve-the-name-of-the-sas-program-code-file/832455/3 "2019-04-13T00:07:26Z")

</div>

This seems on point [24301 - How to retrieve the program name that is currently running in batch mode or interactively](http://support.sas.com/kb/24/301.html)

"To retrieve the name of the current program when you are running SAS®in batch mode, you can issue the following statement:

%put The current program is %sysfunc(getoption(sysin));"
