Help using Base SAS procedures

Splitting a numeric variable

Reply
Occasional Contributor
Posts: 10

Splitting a numeric variable

Hi,

I have a simple question. If I have a numeric variable of a certain length, how can I select only certain digits of this variable into a new variable in a PROC SQL step? I am looking for a function similar to SUBSTRN for strings that would let me select, say, the left-hand 3 digits of a nine-digit number, or the digits 4 through 6 of this number.....

Many thanks,
R.
Trusted Advisor
Posts: 2,116

Re: Splitting a numeric variable

Use the PUT function to convert the number into a formatted string and then you can use the SUBSTR function to pull out the piece.

Doc Muhlbaier
Duke
Ask a Question
Discussion stats
  • 1 reply
  • 170 views
  • 0 likes
  • 2 in conversation