Example 9.18 Cleaning Character Data Values
Goal
Apply several data cleaning rules to a character variable. Modify the case of words according to value and position in the value.
Example Features
Featured Step | DATA step |
Featured Step Options and Statements | Hash object in the DATA step COUNTW, LOWCASE, PROPCASE, and SCAN functions |
Related Technique | DATA step, macro variables |
Input Data Sets
The five observations in data set UNEDITED_TITLES have one character variable.
UNEDITED_TITLES Obs titletext 1 of interest to all 2 up at the crack of dawn 3 the best of ? 4 anything but... 5 OUTSIDE-IN AND INSIDE-OUT
Data set LCWORDS contains the words that should be lowercase in the edited text value.
LCWORDS Obs lcword 1 a 2 an 3 the 4 at 5 by 6 for 7 in ...
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.