To read numeric values of a variable

Reply
N/A
Posts: 0

To read numeric values of a variable

Hi All,

I have a variable whose values are both numeric and charaacters.e.g., 14.2 MG/DL, 19.2 %, no result 12.13 mmol/l, etc... its a mixed of different units r values. My question is 'Is it possible to read only the numeric portion of these values ie. 14.2, 19.2 (if it is text mark as .) 12.13, etc....Will this work with substring & scan function.

It would b helpful if I can have the solution ASAP.
Thanks in advance.
Priya
Frequent Contributor
Posts: 95

Re: To read numeric values of a variable

I start with scan and see how far that gets you. You could even add a scan for the second 'word' if you want to capture the units of measure.

For example:
data work.values;
input valstr $16.;
cards;
14.2 MG/DL
19.2 %
no result
12.13 mmol/l
;
run;

data work.values;
set work.values;
length valnum 8.;
valnum = scan(valstr, 1, " ");
run;
N/A
Posts: 0

Re: To read numeric values of a variable

hai,

i have seen once u posted that u have SAS certicifation question bank.Can u forward to me. I am planning to take Base SAS certification exam in next month.

Thanqs in advance.
Ask a Question
Discussion stats
  • 2 replies
  • 339 views
  • 0 likes
  • 2 in conversation