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

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?

 

LABVALNUMLABCHARLAB
77 
NEG NEG
-3-3 
+ +
2-4 2-4
1.51.5 
2+ 2+
98.698.6 
12.77312.773 
YELLOW YELLOW
< 2.5 < 2.5
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The easiest way would be to suppress all the usgly messages about invalid data:

 

numlab = input(labval, ??12.);

View solution in original post

2 REPLIES 2
Astounding
PROC Star

The easiest way would be to suppress all the usgly messages about invalid data:

 

numlab = input(labval, ??12.);

djbateman
Lapis Lazuli | Level 10

I was never aware of the ? and ?? format modifier until now.  Thank you so much!

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 923 views
  • 0 likes
  • 2 in conversation