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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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