BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Doug____
Pyrite | Level 9

At startup, I'm calling code which uses the SASHELP.VEXTFL dataset to determine the path where the program sits. How can this be used in EG so I can do program editing and testing there?

1 ACCEPTED SOLUTION

Accepted Solutions
Doug____
Pyrite | Level 9
I got something to work. First I check if the _SASPROGRAMFILE macro variable exists. If it does then I parse the path as needed. If it does not, I use the SASELP.VEXTFL table to obtain the location of the program file. Because the _SASPROGRAMFILE variable contains single quotes, I use the DEQUOTE function to remove them for later processing. Appears to work on both clients.

View solution in original post

5 REPLIES 5
ChrisHemedinger
Community Manager

SAS Enterprise Guide sets a number of global macro variables that you can reference in your code.

 

Macro Variable

Description

_CLIENTAPP

Name of the client application

_CLIENTMACHINE   

Client machine node name

_CLIENTPROCESSFLOWNAME

Name of the process flow

_CLIENTPROJECTNAME

File name for the project

_CLIENTPROJECTPATH

Full path and file name for the project

_CLIENTTASKFILTER

Filter that is defined for the task. You can use this macro variable in the titles and footnotes of the task so that the filter information is displayed in the title or footnote of your results.

_CLIENTTASKLABEL

Label for the current task. This is the text label that is displayed in the Project pane and the process flow.

_CLIENTUSERID

User ID of the client user

_CLIENTUSERNAME

Full user name, if that information is available

_CLIENTVERSION

Application version, including build number

_SASHOSTNAME

Server node name (IP address, DNS name, or DCOM name)

_SASPROGRAMFILE

Full path and file name of the SAS program that is currently being run. This macro variable is available only for SAS program files that are saved on the same server on which your SAS Enterprise Guide code is being run.

_SASSERVERNAME

Name of the logical server

 

See the list in the EG doc here.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Doug____
Pyrite | Level 9
I am aware of those variables but I want the code to run the same in PC SAS as it does in EG. Those variables are not available in PC SAS. I want platform independence so programmers can use either without making changes.
ChrisHemedinger
Community Manager

When using a client application like EG or SAS Studio, the client is aware of the original location of a SAS program file but the SAS session doesn't necessarily track it (in the external files table you're relying on). In Base SAS on the PC, the app is both the client (display manager) and the server, so it manages the opening/tracking of these files. But with EG and SAS Studio that responsibility is separate.

 

You can use some %if/%then logic to detect what environment you're running in (PC SAS, EG, Studio, batch) and set things up accordingly. More work for you.

 

Also some traditional uses of this (read files or store output in a path relative to the SAS program file location) won't make sense here, because your original SAS file might be on a local machine with EG, while the SAS session is running on a different machine where you cannot directly reference the local machine with your code.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
Doug____
Pyrite | Level 9
I got something to work. First I check if the _SASPROGRAMFILE macro variable exists. If it does then I parse the path as needed. If it does not, I use the SASELP.VEXTFL table to obtain the location of the program file. Because the _SASPROGRAMFILE variable contains single quotes, I use the DEQUOTE function to remove them for later processing. Appears to work on both clients.
Tom
Super User Tom
Super User

@Doug____ wrote:

At startup, I'm calling code which uses the SASHELP.VEXTFL dataset to determine the path where the program sits. How can this be used in EG so I can do program editing and testing there?


If you want to know where some defined fileref is point use the PATHNAME() function.

If you want to know where the program SAS is running you can just check the SYSIN option value.

Why would you want to query that view? What exactly are you look for? 

Are you trying to guess what program the user of Display Manager might have last opened?  That might have nothing to do with what statements they submitted.

Are you trying to guess what step in which Enterprise Guide project submitted the current block of code to SAS to run?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 951 views
  • 0 likes
  • 3 in conversation