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

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.