Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
Variable Attributes [4-17]


Attribute #2: Variable Label
Picture

Variable Label is the description of the variable.

It is optional.

Some variables have a label and others don't.
Picture
Picture

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)".
​
Picture

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.
Picture

The label from the EngineSize variable is updated.
Picture

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:

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.
Next

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.

Already a member? Go to member's area.