Quartz | Level 8

## Convert char with symbols to numeric

I have a variable that looks as follows. It is in character format [Length - 9, Format - \$9., informat - \$9.] with * in some observations. I would like to know how I can convert this to numeric values?

```_09015C_1_VALUE
1.28
1.52 *
1.50 *
1.58 *
1.74 *
1.18
1.01
1.61 *```

I have tried these steps, but it didn't work

*SC=_09015C_1_VALUE*1;
SC=input(_09015C_1_VALUE,9.0);

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

## Re: Convert char with symbols to numeric

Since there always seems to be a blank, use that to extract the numeric part before it:

``````data want;
input _09015C_1_VALUE \$9.;
numvalue = input(scan(_09015C_1_VALUE,1," "),5.);
datalines;
1.28
1.52 *
1.50 *
1.58 *
1.74 *
1.18
1.01
1.61 *
;``````
4 REPLIES 4
Super User

## Re: Convert char with symbols to numeric

Since there always seems to be a blank, use that to extract the numeric part before it:

``````data want;
input _09015C_1_VALUE \$9.;
numvalue = input(scan(_09015C_1_VALUE,1," "),5.);
datalines;
1.28
1.52 *
1.50 *
1.58 *
1.74 *
1.18
1.01
1.61 *
;``````
Quartz | Level 8

## Re: Convert char with symbols to numeric

Can you tell me what is the meaning of 1 and 5. in the code?
numvalue = input(scan(_09015C_1_VALUE,1," "),5.);
Super User

## Re: Convert char with symbols to numeric

1 means "first part", and the 5. is an informat.

I invite you to study the documentation of the SCAN Function, the INPUT Function, and the w.d Informat.

Quartz | Level 8

## Re: Convert char with symbols to numeric

Thank you so much Kurt!
Discussion stats
• 4 replies
• 481 views
• 0 likes
• 2 in conversation