Sentry Page Protection
Variable Attributes [4-17]
Attribute #2: Variable Label
Variable Label is the description of the variable.
It is optional.
Some variables have a label and others don't.
A label can be added or modified using the Label statement.
Example
Locate the CARS data set from the SASHelp library.
Open the Column Properties of the EngineSize variable.
The variable has a label of "Engine Size (L)".
The label can be modified using a Label statement.
Example
Data Cars;
Set SASHelp.cars;
Label EngineSize = "This is a modified label!";
Run;
Run the code above on SAS Studio.
Then go to the WORK library.
The label from the EngineSize variable is updated.
Note: the label is updated in the data set from the WORK library, not the SASHelp library.
(try it!)
Variable label cannot exceed 256 characters.
Unlike variable name, it allows spaces, special symbols or characters.
Is it necessary to add a variable label?
No, variable label is usually not needed.
However, variable label can be used to add the full description of the data.
This is generally preferred when having to send the data sets to third party users (i.e. clients).
Exercise
Copy and run the ADMISSION data set from the yellow box below:
Copy and run the ADMISSION data set from the yellow box below:
The ADMISSION data set above contains 4 variables:
- Applicant
- Crit1: Admission Criteria 1
- Crit2: Admission Criteria 2
- Crit3: Admission Criteria 3
Label Crit1, Crit2 and Crit3 as below:
Crit1:
Applicant's GPA above 3.5
Crit2:
Applicant's did not fail more than 4 courses
Crit3:
Applicant's has a Bachelor of Science degree
Create any data set or variable if needed.
Need some help?
HINT:
Only one label statement is needed to add the labels to all three variables.
SOLUTION:
Data Admission2;
Set Admission;
Label
Crit1 = "Applicant's GPA above 3.5"
Crit2 = "Applicant's did not fail more than 4 courses"
Crit3 = "Applicant's has a Bachelor of Science degree";
Run;
Fill out my online form.