BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I have a character field containing a mix of numeric and character data (ie. <20 0.555 4500 NA etc etc).

I want to select only numeric data and compare with a similar field for comparison. So I wrote:

IF VERIFY(EDRESULT,' 0123456789.') NE 0 THEN ;
ELSE DO;
IF INPUT(EDRESULT,8.2) < INPUT(EDLORNG,8.2) THEN EDFLAG = 'L';
ELSE IF INPUT(EDRESULT,8.2) > INPUT(EDHIRNG,8.2) THEN EDFLAG = 'H';
END;

But I'm not sure how format I should use to read in these data. Since it contains different decimal points, I can't just use one format (8.2). It gives a mix of correct and incorrect answers when I use this format.

Any idea?

Thank you.
James
2 REPLIES 2
Chevell_sas
SAS Employee
Try using the BEST. format which allows SAS to choose the format providing the most information about the value.
deleted_user
Not applicable
also simply using the informat 8. or 12. or... might be ok. You should not read with a format with decimal points in. If there comes something with decimals it is read ok anyway.

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