Chapter Contents

Previous

Next
SAS Companion for the CMS Environment

Accessing System Variables

Under CMS, SAS provides a mechanism for accessing system variables that have been created with the CMS GLOBALV command. You can access GLOBALV variables directly from SAS by using either the %SYSGET macro function or the SYSGET DATA step function.

The group name and variable name can be any that are valid for the CMS GLOBALV command (see the VM/ESA CMS Command Reference). If you omit the group name, the variable is extracted from the group SASV7 if it is found there, or else from the default group UNNAMED. If the variable has not been set via GLOBALV, SYSGET or %SYSGET returns an error.

SYSGET uses the EXECCOMM interface and therefore the length of the variable name is limited to 250 characters. GLOBALV imposes a maximum length of 255 characters on the variable's value. The full length is returned by SYSGET or %SYSGET if the SAS variable is assigned a sufficient length. Otherwise the value returned by SYSGET or %SYSGET is truncated to the SAS variable's length, which is 200 characters by default.

CAUTION:
Using SYSGET or %SYSGET can replace the value of an existing variable in your SAS EXEC. SYSGET and %SYSGET use the EXECCOMM interface, which assigns variables in the SAS EXEC. If the variable you assign with SYSGET or %SYSGET has the same name as an existing variable in the currently active EXEC, the existing variable will receive the value specified by SYSGET or %SYSGET. This change to a global variable could adversely affect other aspects of your SAS session.  [cautend]


Using the SYSGET DATA Step Function

When you use the SYSGET DATA step function to access system variables, you must enclose the string that specifies the group name and the variable name in single quotes:

SYSGET('group-name variable-name')

For example, if the group name is MINE and the variable name is TIME, your DATA step might look like this:


data test;
   x=sysget('mine time');
   . . . more lines
of data . . .
run;


Using the %SYSGET Macro Function

When you use the %SYSGET macro function to access system variables, do not enclose the string that specifies the group name and the variable name in single quotes:

%SYSGET(group-name variable-name)

For example, if the group name is MINE and the variable name is TIME, your code might look like this:


%let x=%sysget(mine time);


Chapter Contents

Previous

Next

Top of Page

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.