Assigns a variable label to a specified character variable.
| Category: | Variable Control |
specifies any SAS variable. If variable-1 does not have a label, the variable name is assigned as the value of variable-2.
specifies any SAS character variable. Variable labels can be up to 256 characters long. Therefore, the length of variable-2 should be at least 256 characters to avoid truncating variable labels.
| Note | To conserve space, you should set the length of variable-2 to the length of the label for variable-1, if it is known. |
data new;
set old;
/* lab is not in either array */
length lab $256;
/* all character variables in old */
array abc{*} _character_;
/* all numeric variables in old */
array def{*} _numeric_;
do i=1 to dim(abc);
/* get label of character variable */
call label(abc{i},lab);
/* write label to an observation */
output;
end;
do j=1 to dim(def);
/* get label of numeric variable */
call label(def{j},lab);
/* write label to an observation */
output;
end;
stop;
keep lab;
run;