BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

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
Kurt_Bremser
Super User

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 *
;

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

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 *
;
mantubiradar19
Quartz | Level 8
Can you tell me what is the meaning of 1 and 5. in the code?
numvalue = input(scan(_09015C_1_VALUE,1," "),5.);
mantubiradar19
Quartz | Level 8
Thank you so much Kurt!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 743 views
  • 0 likes
  • 2 in conversation