From the course: SAS® 9.4 Cert Prep: Part 10 Manipulating Data with Functions

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Demo: Using character functions to extract words from a string

Demo: Using character functions to extract words from a string - SAS Tutorial

From the course: SAS® 9.4 Cert Prep: Part 10 Manipulating Data with Functions

Demo: Using character functions to extract words from a string

- (Instructor) Here we will use the SCAN function to extract words from a character column and then use the PROPCASE function to standardize casing. We're reading the weather japan table and we're doing a little bit of clean up all ready by using this statement to remove any extra blanks that there may be in the location column. Then, we're creating two new columns. City, we'll use the scan function to read the first word from location and prefecture will be the second word from location. So lets run the code as is and see how it looks. Looking at the city and prefecture columns, the first several rows look good. However, notice when we get to row eight, the city should be the full string Miyake-Jima. However, because the hyphen is a delimiter, the first word is Miyake and the second word is Jima. That's a problem. So how do we get the entire string to be the city and Tokyo to be the prefecture. Let's go back to the code…

Contents