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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1411 views
  • 0 likes
  • 3 in conversation