Help using Base SAS procedures

Numbers and Alphas in Character Field

Posts: 61

Numbers and Alphas in Character Field

Hello -

I am looking for some assistance.   I have a character field variable that contains data with both text and numbers.  I am looking to change the data that is text into number zero and keep the text that looks like numbers and convert to number for further calculation/analysis.  Is there a way to do this?  Any help would be greatly appreciated.   

Super User
Super User
Posts: 8,073

Re: Numbers and Alphas in Character Field

Posted in reply to Suzanne_Ed

Why zero?

Create a new variable from the old variable.

Example: Create NUMBER from ALPHA.

data want ;

  set have ;

  number = input(alpha,??20.);

  if number = . then number = 0;


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation