BookmarkSubscribeRSS Feed
dwhalen
Calcite | Level 5

How can I get the path of a script's own location (where the .sas file is saved), and assign that path to a variable?

 

Python equivalent would be:

import os
path = os.path.dirname(__file__)

 

I'm using EGuide on SAS 9.04

4 REPLIES 4
Kurt_Bremser
Super User

With EG, "path" can mean a lot of things:

  • the path to the directory from which a project file was loaded
  • the name and location of a node within a project file
  • the path where a code node is stored externally (if the EG project has a link to it instead of an embedded program)
  • the path of a file that was %INCLUDEd on the server.
  • the path of the SAS executable
  • the path of the EG executable on Windows
dwhalen
Calcite | Level 5

Meaning:

I create a script, "example.sas"

I open that script in EGuide

I run the script, and in that script, the path where "example.sas" is assigned to a variable

ChrisHemedinger
Community Manager

Check this list of special macro variables in SAS Enterprise Guide.  Check the SAS Enterprise Guide online help for the latest - captured here for v8.3:

 

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

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
Reeza
Super User
SAS already contains these values in macro variables and you can reference them in your code by using &variableName.

Here's a quick intro for you: https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1015 views
  • 4 likes
  • 4 in conversation