O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example 9.17 Extracting a Character String without Breaking the Text in the Middle of a Word

Goal

Extract from a variable a character string that is no longer than a specified length and that does not end in the middle of a word.

Example Features

Featured StepDATA step
Featured Step Options and StatementsANYPUNCT, ANYSPACE, LARGEST, and SUBSTR functions

Input Data Set

Data set WORKPLACE has comments from six employees.

                          WORKPLACE

  Obs    comments
   1     Cannot discuss work-related issues with my supervisor.
   2     Need flex scheduling&job-sharing options.
   3     Add closer parking areas.
   4     Love the cafeteria
   5     More programs for career advancement
   6     Mentoring? Coaching? Either available?

Resulting Data Set

Output 9.17 TRUNC_COMMENTS Data Set

 Example 9.17 TRUNC_COMMENTS ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required