Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left 6 characters of a 10 character field

Status
Not open for further replies.

mbliss

Programmer
Aug 28, 2002
3
US
I need to get the left 6 characters from a 10 character field. Does anyone know how to do this?
 
Hi,

This is an easy problem to sort out. You need to use the substr function which has the format substr(fieldname, character to start at, number of characters to take). So to take the left 6 characters of a field your start position would be character 1 and you would need to take 6 characters.

To give you an example put this line of code in a data step (you will need to change the field names to fit your dataset):

newfield=substr(oldfield,1,6).

Hopr this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top