SASnR Home

Character Function List


Below is a table showing the character function equivalents between SAS and R Tidyverse.

 

Purpose SAS  R Tidyverse (Stringr)
Convert the text case to upper case letters upcase str_to_upper
Convert the text case to lower case letters lowcase str_to_lower
     
Replace a character with another character translate str_replace_all
Replace a word with another word tranwrd str_replace_all
     
Remove all instances of specific character (s) compress str_remove_all or str_replace_all
Remove trailing space - space at the end of a string trim str_trim
Remove leading space and trailing space - both at the beginning and end of a string strip str_trim
     
Find the position of a substring within another string find str_locate
     
Concatenate multiple strings into a single string cats str_c
     
Find the number of characters in a string length str_length
     
Count the number of instances of a substring within a string count str_count
     
Extract a specific word from a string scan word
Extract a substring from a string based on position and required length substr str_sub

SASnR Home