SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Transforming Data with SAS Functions
Modifying Character Values with Functions


Introduction to Modifying Character Values

This section teaches you how to use SAS functions to manipulate character variable values. After completing this section, you will be able to

  • replace the contents of a character value
  • trim trailing blanks from a character value
  • search a character value and extract a portion of the value
  • convert a character value to uppercase or lowercase.

To begin, let's look at some of the modifications that need to be made to the character variables in Hrd.Temp. These modifications include

  • separating the values of one variable into multiple variables

SAS Data
Name LastName FirstName MiddleName
CICHOCK, ELIZABETH MARIE --> CICHOCK ELIZABETH MARIE
BENINCASA, HANNAH LEE --> BENINCASA HANNAH LEE


  • replacing a portion of a character variable's values

SAS Data
Phone Phone
6224549 --> 4334549
6223251 --> 4333251


  • searching for a specific string within a variable's values.

SAS Data
Job
filing, administrative duties
bookkeeping, word processing, accounting


Character Functions

The character functions listed below can help you complete these tasks. You will learn about these functions as you continue this lesson.


Function Purpose
SCAN Returns a specified word from a character value.
SUBSTR Extracts a substring or replaces character values.
TRIM Trims trailing blanks from character values.
INDEX Searches a character value for a specific string.
UPCASE Converts all letters in a value to uppercase.
LOWCASE Converts all letters in a value to lowercase.



  |next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement