BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
deleted_user
Not applicable
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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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