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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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