BookmarkSubscribeRSS Feed
Proc_Canada
Calcite | Level 5

In SAS Viya, when running code in SAS Studio, the automatic macro variable _SASPROGRAMFILE contains the full path (or URI) of the program file. However, when running the same program using the VS Code SAS extension, _SASPROGRAMFILE resolves to the filename only, without the directory path.

Is there a way to determine the full path of the program file when running from VS Code? Does SAS Viya expose this information through any existing environment variable, or other macro variable?
Any hints or recommended approaches?

4 REPLIES 4
ChrisHemedinger
Community Manager

The VS Code extension also adds the _SASPROGRAMFILE macro variable. Example:

%let _SASPROGRAMFILE = %nrquote(%nrstr(c:\Projects\sas-programs-misc\bird-events.sas));

 

Let me know if you're not seeing that in your case.  You can also report issues as needed in the GitHub project:

https://github.com/sassoftware/vscode-sas-extension/issues

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Proc_Canada
Calcite | Level 5

May I know what version are you using? I am using the newest version and it does not work.

 

Below are output of same program file, which has only one statement (%put &=_sasprogramfile;).

 

SAS Studio output:

_SASPROGRAMFILE=/export/viya/homes/xxxx/Work/test/a.sas

 %put &=_sasprogramfile;
_SASPROGRAMFILE=\a.sas

 

ChrisHemedinger
Community Manager

Ah, I see. It's working as expected with local files that you open/create in VS Code, but not for "remote" files that you open from the SAS Content folders. Feel free to comment on the issue in GitHub and see if it can be prioritized for a fix.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 224 views
  • 1 like
  • 2 in conversation