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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.