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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 773 views
  • 0 likes
  • 2 in conversation