Defining Environment Variables in UNIX Environments


Defining Environment Variables in UNIX Environments

What is an Environment Variable?

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 SASV9_OPTIONS environment variable to specify system options and the SASV9_CONFIG environment variable to specify a configuration file. You can also use environment variables as filerefs and librefs in various statements and commands.

Note  

A SAS/ACCESS product initializes the environment variables it needs when loading. Any changes that you make to an environment variable after initialization will not be recognized. For more information, see the documentation for your SAS/ACCESS product.

How to Define an Environment Variable for Your Shell

The way in which you define an environment variable depends on the shell that you are running. (To determine which shell you are running, type ps at the command prompt or echo $shell to see the current value of the SHELL environment variable.)

Bourne and Korn Shells

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.

C Shell

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 

Displaying the Value of an Environment Variable

To display the values of individual environment variables, use the echo command and parameter substitution. An example is: echo $SHELL which returns the current value of the SHELL environment variable. Use the env (or printenv ) command to display all environment variables and their current values.




SAS 9.1 Companion for UNIX Environments
SAS 9.1 Companion For Unix Enivronments
ISBN: 1590472101
EAN: 2147483647
Year: 2004
Pages: 185
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net