Help using Base SAS procedures

character to numeric

Reply
N/A
Posts: 0

character to numeric

I have some data that I cannot clean appropriately. I have read in some data that contains single quotes in variables that I want as numeric. I have tried to create a new variable by multiplyingh the old variable by 1 and also using the input function of creating a new variable, but the new variable always has a missing value.

Below is the error I get.

NOTE: Invalid numeric data, '44,178.67' , at line 640 column 9
N/A
Posts: 0

Re: character to numeric

Just use this:

B=INPUT(COMPRESS(A,'0123456789.','k'),8.);

where A is your dirty data and B will be your clean numerical one.

Ike Eisenhauer Message was edited by: WDEisenhauer
N/A
Posts: 0

Re: character to numeric

This worked great. Thank you.

~ Max
N/A
Posts: 1

Re: character to numeric

This is a superb solution to a problem I have. I wanted to keep any numeric values in a field but eliminate the characters. This was perfect for that situation.
Ask a Question
Discussion stats
  • 3 replies
  • 122 views
  • 0 likes
  • 2 in conversation