Chapter Contents

Previous

Next
SAS Companion for UNIX Environments

Defining Environment Variables

Environment variables are variables that apply to both the current shell and to any subshells it creates (for example, when you send a job to the background or execute a script). If you change the value of an environment variable, the change is passed forward to subsequent shells but not backward to the parent shell.

In a SAS session, you can use the SASV8_OPTIONS environment variable to specifiy system options and the SASV8_CONFIG environment variable to specify a configuration file. You can also use environment variables as filerefs and librefs in various statements and commands.

The way in which you define an environment variable depends on the shell that you are running. In the Bourne shell and in the Korn shell, use the export command to export one or more variables to the environment. For example, these commands make the value of the variable scname available to all subsequent shell scripts:

$ scname=phonelist
$ export scname
In the Korn shell, you can combine these into one command:
$ export scname=phonelist

If you change the value of scname, the new value affects both the shell variable and the environment variable. If you do not export a variable, only the shell script in which you define has access to its value.

In the C shell, you set (define and export) environment variables with the setenv (set environment) command. For example, this command is equivalent to the commands shown previously:

% setenv scname phonelist

Use the echo command and parameter substitution to display the values of individual environment variables, just as you do for shell variables, for example: echo $SHELLUse the env (or printenv) command to display all environment variables and their current values.


Chapter Contents

Previous

Next

Top of Page

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