BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a very simple question about case selection in a data step. I wonder what is the command for selecting cases with integral values only, that is, value = 1, 2, 3, ... but I want to exclude the cases with values of 1.5, 2.5, etc. This sounds so simple, something like but I cannot find the proper command. Thanks! Message was edited by: SASLooker
4 REPLIES 4
martha_sas
SAS Employee
Can you use the mod function? (Since mod(x,1)=0 only if x is an integer). For example, if you want to keep only observations from set 'one' where variable 'x' is integral, you can do this:

data newdata;
set one;
where mod(x,1)=0;
run;
deleted_user
Not applicable
thanks! I'll try that.
ieva
Pyrite | Level 9
Another simple way how to do that:

data two;
set one;
where x=int(x);
run;
deleted_user
Not applicable
Thanks for the two tips. It appears the mod way works better for my case. The int way also works, but it also includes the blanks or missing values, which I don't want. Thanks for both helpers!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 932 views
  • 0 likes
  • 3 in conversation