| Text-only | Table of Contents (frame/ no frame) |
| (9) Variables |
|
Setting and exporting variables
srcfile=dataset1
set
unset srcfile
srcfile=
export srcfile
export
$srcfile
${srcfile}
Example:
datafile=census2000
# Tries to find $datafile_part1, which doesn't exist
echo $datafile_part1.sas
# This is what we intended
echo ${datafile}_part1.sas
${datafile-default}
$datafile, if it has been defined, otherwise use the string "default". This is an easy
way to allow for optional variables, and have sensible defaults if they haven't been set. If datafile was
undefined, it remains so.
${datafile=default}
datafile has not been defined, set it to the string "default".
${datafile+default}
datafile has been defined, use the string "default", otherwise use null. In this case the
actual value $datafile is not used.
${datafile?"error message"}
$datafile, if it has been defined, otherwise display datafile: error message.
This is used for diagnostics when a variable should have been set and there is no sensible default value to use.
var=value command args
| variables.src last modified Feb 10, 2005 | Introduction | Table of Contents (frame/no frame) |
Printable (single file) |
© Dartmouth College |