As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Another Way to Use the SUBSTR Function

From sasCommunity
Jump to: navigation, search

You can use the SUBSTR function to replace values within a variable. Suppose you have a variable called Employee_ID, where the first two characters indicate the branch an employee is assigned to:

LNAME	FNAME	EMPLOYEE_ID
Barczak	George	CP436
Adams	Linda	LA543
Preiss	Gloria	AU942

To change the first two letters of the employee ID to "DA", use the SUBSTR function on the left side of the assignment statement:

substr(employee_id,1,2)='DA';

Result:

LNAME	FNAME	EMPLOYEE_ID
Barczak	George	DA436
Adams	Linda	DA543
Preiss	Gloria	DA942
Submitted By LindaJAdams