I want to change a character variable to a numeric variable. The column name is VALUE (length=8, type=char, format=$8., informat=$8.) and the character values in the VALUE column look like this:
VALUE
-2,88
2,68
-6,22
-4,57
5,42
and so on
I know that I should use the input function and I want to change the commas to decimals points. Data is coming from Europe so it's using the comma instead of a decimal point.
num_value=input(value,????);
Any help is appreciated.
Something like
data have;
input VALUE $;
datalines;
-2,88
2,68
-6,22
-4,57
5,42
;
data want;
set have;
numval = input(value, commax8.2);
run;
Something like
data have;
input VALUE $;
datalines;
-2,88
2,68
-6,22
-4,57
5,42
;
data want;
set have;
numval = input(value, commax8.2);
run;
Depending on what your data might contain, a slight change could be in order. Compare these results:
data have;
input VALUE $;
datalines;
-28
2,68
-6,22
-4,57
5
;
data want;
set have;
numval1 = input(value, commax8.2);
numval2 = input(value, commax8.);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.