Remove Leading, Trailing, all space in SAS using strip(), trim() and compress() function in SAS. STRIP function in SAS removes all leading and trailing blanks. TRIM function in SAS removes all trailing blanks. COMPRESS function in SAS removes all blanks
- STRIP function in SAS – removes all leading and trailing blanks
- TRIM function in SAS – removes all trailing blanks
- COMPRESS function in SAS – removes all blanks
So we will be using EMP_DET Table in our example
STRIP function – removes all leading and trailing blanks
STRIP Function in SAS Removes all the leading and Trailing spaces. STRIP() Function takes column name as argument and removes the leading and trailing spaces
/* STRIP function - removes all leading and trailing blanks */ data EMP_DET1; set EMP_DET; state_new = STRIP(state_name_code); run;
So the resultant table with the leading and trailing spaces removed will be
TRIM function – removes all trailing blanks
TRIM Function in SAS Removes all the Trailing spaces. TRIM() Function in SAS takes column name as argument and removes the trailing space.
/* TRIM function - removes all trailing blanks */ data EMP_DET1; set EMP_DET; state_new = TRIM(state_name_code); run;
So the resultant table with trailing spaces removed will be
COMPRESS function – removes all the spaces or blanks
COMPRESS Function in SAS Removes all the spaces. COMPRESS() Function takes column name as argument and removes all the spaces
/* COMPRESS function - remove all Blanks */ data EMP_DET1; set EMP_DET; state_new = COMPRESS(state_name_code); run;
So the resultant table with all the spaces removed will be