Вы находитесь на странице: 1из 6

SAS in Data

Cleaning
Changing Text Words
TRANWRD(source,target,replacement)
replaces or removes all occurrences of a word in
a character string

Will change all occurrences of the target character


string with the new one.

Supplier= Tranwrd(supplier, "Incorporated", "Inc.");


Extract a specific word from a
string.
SCAN(argument,n<,delimiters>)returns a given
word from a character expression

Extracts the n-th word from the string. The


delimiters can define the word. Default
delimiters are blank and special characters.

If scan(Reverse(Trim(supplier)),1, " ") = "& " then


do;
Extracting specific characters by
position
var=SUBSTR(argument,position<,n>)
extracts a substring from an argument. (var is any
valid SAS variable name.)

Position starts with 1. n is number of characters to


extract

Department= Substr(pcode,1,2);
If Then
IF condition THEN action;
Or
IF condition THEN DO;
Statements
END;
Multiple output data sets
DATA One Two;
SET Input;

OUTPUT One;

OUTPUT Two;

Вам также может понравиться