10月 092012
 

You might know about the many automatic macro variables that are available in SAS. They provide plenty of information about the SAS environment, such as the current user (SYSUSERID), the SAS version (SYSVER and SASVLONG), and the operating system where SAS is running (SYSCP and SYSCPL). That information is often useful for your SAS programs and reporting output.

Did you know that SAS Enterprise Guide also generates several macro variables? These provide information about the SAS Enterprise Guide environment, which is often different than the SAS environment when you're connected to a remote SAS workspace.

You can use these macro variables to code various logic tricks into your programs, such as to determine where the current project file resides and assign a library to its path.

Or, even if you don't write SAS programs, you can use the macro variables in task titles and footnotes. For example:

Generated by &_CLIENTUSERNAME (&_CLIENTUSERID) with SAS Enterprise Guide &_CLIENTVERSION

For me, this yields:

Generated by 'Chris Hemedinger' ('sascrh') with SAS Enterprise Guide '5.100.0.12019'

Here's the complete list of the generated macro variables (as of SAS Enterprise Guide 4.3 and 5.1). These macro variables are also generated in the SAS Add-In for Microsoft Office. You can always find this list in the SAS Enterprise Guide online help, which you access from the help menu. Simply search the keyword index for "macro".

Macro Variable Description
_CLIENTAPP Name of the client application.
_CLIENTMACHINE Client machine node name.
_CLIENTPROJECTNAME The filename for the project.
_CLIENTPROJECTPATH The full path and filename for the project.
_CLIENTTASKFILTER The 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 tree 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 or DNS name).
_SASPROGRAMFILE The full path and filename 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.

And remember, you can easily see all of the available macro variables, along with their current values, by using the SAS Macro Variable viewer custom task.

tags: macro programming, SAS Enterprise Guide

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)