Solved
New Contributor
Posts: 3

# character to numeric data type conversion issues

hi good morning to all,

I am having one dataset name ds1 which having three variables:

original dataset:

data ds1;
input id          subject\$      marks;

datalines;
101          maths           78
102          science         88
;
run;

new dataset:

data ds3;
set ds1;
sub_val=input(subject,7.);

run;

as my 2nd variable is a character type I'm trying it to convert into numeric data type but in output results sub_val observation missing but in properties data type it is showing numeric data type.

iam not aware how to resolve this problem set , kindly give some valuable solution regarding this problem.

regards

hemen boro

Accepted Solutions
Solution
‎01-08-2017 02:26 AM
Posts: 4,741

## Re: character to numeric data type conversion issues

[ Edited ]

A w.d informat would allow you to read a string of DIGITS and convert it to a number. You're dealing with strings of letters and there can't be some generic logic to convert such a string into a number.

You can always create your own informat (using proc format with invalue) to do such a conversion.

```NOTE: Invalid argument to function INPUT at line 25 column 10.
id=101 subject=maths marks=78 sub_val=. _ERROR_=1 _N_=1
NOTE: Invalid argument to function INPUT at line 25 column 10.
id=102 subject=science marks=88 sub_val=. _ERROR_=1 _N_=2
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.```

All Replies
Solution
‎01-08-2017 02:26 AM
Posts: 4,741

## Re: character to numeric data type conversion issues

[ Edited ]

A w.d informat would allow you to read a string of DIGITS and convert it to a number. You're dealing with strings of letters and there can't be some generic logic to convert such a string into a number.

You can always create your own informat (using proc format with invalue) to do such a conversion.

```NOTE: Invalid argument to function INPUT at line 25 column 10.
id=101 subject=maths marks=78 sub_val=. _ERROR_=1 _N_=1
NOTE: Invalid argument to function INPUT at line 25 column 10.
id=102 subject=science marks=88 sub_val=. _ERROR_=1 _N_=2
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.```

New Contributor
Posts: 3

## Re: character to numeric data type conversion issues

hi patrick,

thanks  a lot for giving valuable help in this regards.

and wish u a happy belated new year ahead.

thanks

hemen boro

☑ This topic is solved.