SAS Programming

DATA Step, Macro, Functions and more
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

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
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/

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 1584 views
  • 4 likes
  • 4 in conversation