Sentry Page Protection
Variable Attributes [6-17]
Attribute #3: Variable Type (Character)
Character variable is used when you have text values such as:
- Name
- ID
- Comment
- Description
Let's take a look at an example.
All of the variables in this data set are character variables.
What about the Age?
You might have noticed that the AGE variable is also listed as a character variable.
What about the Age?
You might have noticed that the AGE variable is also listed as a character variable.
It is indeed:
Unlike a numeric variable, there is no restriction on the type of data a character variable can capture.
A character variable can handle either text values (e.g. ID, comments) or numeric values (e.g. age, dollar amount).
However, it is generally a good programming practice to keep the numeric values under a numeric variable for computation purposes.
Data Truncation with Character Variable
Data Truncation (cutoff) is a very common error for character variable.
This will be explained in details in the next session.
Summary of Character Variable
- Character variable is used when working with text values such as name, comment, and description.
- Character variable can handle both numeric and character values. However, it is a good programming practice to keep the numeric values under a numeric variable for computation purposes.
- Data truncation is a very common problem with character variable.
Exercise
Which of the following values are best kept under a character variable?
(a) This is a comment.
(b) CUSTID10010
(c) NA
(d) (a) and (b)
(e) all of the above
(a) This is a comment.
(b) CUSTID10010
(c) NA
(d) (a) and (b)
(e) all of the above
Need some help?
HINT:
Can any value(s) above be used in the summary statistics calculation?
SOLUTION:
(e)
Fill out my online form.