I have a list of lab values in a character variable, and I need to store all the numeric values in a numeric variable. I thought I had it made when I found the NOTDIGIT() function. That works great for integer data, but then I realized that I am dealing with decimal and negative values. Is there a way to detect just these characters? I know I could just use INPUT(). That would convert any number-like value to numeric, but for all the character values, I would be left with a lot of ugly notes filling up my log (NOTE: Invalid argument to function INPUT at line XXX column YYY.).
I have some example data below. Is there away to get LABVAL to the NUMLAB and CHARLAB, respectively, as I have them?
LABVAL | NUMLAB | CHARLAB |
7 | 7 | |
NEG | NEG | |
-3 | -3 | |
+ | + | |
2-4 | 2-4 | |
1.5 | 1.5 | |
2+ | 2+ | |
98.6 | 98.6 | |
12.773 | 12.773 | |
YELLOW | YELLOW | |
< 2.5 | < 2.5 |
The easiest way would be to suppress all the usgly messages about invalid data:
numlab = input(labval, ??12.);
The easiest way would be to suppress all the usgly messages about invalid data:
numlab = input(labval, ??12.);
I was never aware of the ? and ?? format modifier until now. Thank you so much!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: