Removes leading and trailing white spaces from character strings.
Behavior is the same. Both remove leading and trailing spaces only.
strip(var)
trimws(var)Good practice to apply to character variables before comparison or merge to avoid formatting inconsistencies.
data dm; input USUBJID $ SITEID $; datalines; 101-001 001 ; run; data dm2; set dm; SITEID_CLEAN = strip(SITEID); run;
library(dplyr) dm <- data.frame( USUBJID="101-001", SITEID=" 001 " ) dm <- dm %>% mutate(SITEID_CLEAN = trimws(SITEID))
USUBJID SITEID SITEID_CLEAN 101-001 001 001