DATA Step, Macro, Functions and more

How to check numerica data between ranges

Reply
N/A
Posts: 0

How to check numerica data between ranges

Hi,

I want to check my data if it exists between ranges. Say for example my data is coming as decimals ranging 0.00 to 220.90 then if want to check data if first 3 bytes before decimals in range 140 - 150 and then last two bytes after decimals b/w 80 -89 , how to do this in data step statement.

compress decimals and then use if then else??

Please let me know soon.

thanks,
sasbase
Super Contributor
Super Contributor
Posts: 3,174

Re: How to check numerica data between ranges

Posted in reply to deleted_user
Depends on your SAS variable, whether it is character or numeric type. If character type, recommend converting it to a numeric variable (different name) using the INPUT function, and then do your comparison, doing so in a SAS DATA step. I have provided a link below to a SAS SUG/SGF user community paper which discusses INPUT function and data variable conversion. There are others like this, available by searching at the SAS support website http://support.sas.com/ .

Scott Barry
SBBWorks, Inc.


http://www2.sas.com/proceedings/sugi26/p056-26.pdf
N/A
Posts: 0

Re: How to check numerica data between ranges

Posted in reply to deleted_user
Have you considered using formats, something along these lines:

data have;
input val;
cards;
1
20.5
30.9
140.0
145.2
145.85
200
;
run;

proc format;
value intPart
low - 139.99 = 'Low '
140 - 149.99 = 'Want'
150 - high = 'High'
;
run;

proc format;
value decPart
low - 0.79 = 'Low '
0.8 - 0.89 = 'Want'
0.9 - high = 'High'
;
run;

data want;
set have;
intRange = put(val, intPart.);
decRange = put(val - int(val), decPart.);
run;

proc sql;
create table summary
as
select intRange, decRange, count(val) as count
from want
group by 1,2
;
quit;
Ask a Question
Discussion stats
  • 2 replies
  • 114 views
  • 0 likes
  • 2 in conversation