SAS Variable and Value Labels
Overview
Variable and value labels are used to make the output of SAS more
understandable. For example, you may have used an abbreviation for
the state someone lives in and would like the full name printed out when
used. To associate names with a variables values you use proc formats;
and to associate names with a variable you use label keyword
within the data statement.
Defining variable labels
The label keyword comes after the input statement is completed.
Variable labels are used to provide improved descriptions for variable
names. Assume we have variables Q1 and YRSALES, we could define labels
with the following example:
data test;
input q1 2-6 yrsales 8-12;
label q1='First Quarter Sales'
yrsales='Yearly Sales';
Defining value labels, Proc Format
SAS has a procedure named format to do this. The way that the
format procedure is used is that the format procedure
should be used before the data statement. The format
procedure defines labels associated with a value. For example, to
specify that the value "MD" is Maryland and "VI" is Virginia you would
use the following:
Proc format;
value $stname 'MD'='Maryland' 'VI'='Virginia';
run;
Then in the data statement you must associate the format value with a
variable as in:
data test;
input state $ 1-2 income 4-8;
format state $stname.;
(note: notice the period at the end of the format value, that is required).
Author - Jack Suess
UMBC University Computing Services
Created - 1/15/96