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);
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 *
;
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 *
;
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.