- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-03-2009 07:35 PM
(1211 views)
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
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
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Scott Barry
SBBWorks, Inc.
http://www2.sas.com/proceedings/sugi26/p056-26.pdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;