You can use the label function in SAS to provide label names to variables in a dataset.
The following example shows how to use this function in practice.
Example: Label Variables in SAS
Suppose we create the following dataset in SAS:
/*create dataset*/ data data1; input ID $ x y; datalines; Mavs 99 21 Spurs 93 18 Rockets 88 27 Thunder 91 29 Warriors 104 40 Cavs 93 30 ; run; /*view contents of dataset*/ proc contents data=data1; run;
The output of the proc contents function shows us the name, data type, and length of each of the three variables in our dataset.
However, it might not be obvious what ID, x, and y actually refer to in the dataset.
Fortunately, we can use the label function when creating the dataset to provide specific labels for each variable:
/*create dataset*/ data data1; input ID $ x y; label ID = 'Team' x = 'Points' y = 'Rebounds'; datalines; Mavs 99 21 Spurs 93 18 Rockets 88 27 Thunder 91 29 Warriors 104 40 Cavs 93 30 ; run; /*view contents of dataset*/ proc contents data=data1; run;
Notice that the output of proc contents now contains an extra column called label, which contains the labels for the three variables that we specified.
The following tutorials explain how to perform other common tasks in SAS:
How to Normalize Data in SAS
How to Replace Characters in a String in SAS
How to Replace Missing Values with Zero in SAS
How to Remove Duplicates in SAS