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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 970 views
  • 0 likes
  • 3 in conversation