Help using Base SAS procedures

Simple Question about Integral Values

Reply
N/A
Posts: 0

Simple Question about Integral Values

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
SAS Employee
Posts: 19

Re: Simple Question about Integral Values

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;
N/A
Posts: 0

Re: Simple Question about Integral Values

thanks! I'll try that.
Frequent Contributor
Posts: 82

Re: Simple Question about Integral Values

Another simple way how to do that:

data two;
set one;
where x=int(x);
run;
N/A
Posts: 0

Re: Simple Question about Integral Values

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!
Ask a Question
Discussion stats
  • 4 replies
  • 117 views
  • 0 likes
  • 3 in conversation