## selecting certain age observations

Solved
Regular Contributor
Posts: 182

# selecting certain age observations

I have a freq table that showed my data set contained ages that should not be in my data set and I need to see who these folks are.  I want to select everyone outside of a 2-13 age group and put those folks into a new table.

Is it a If statement, Keep??  I've tried this data step a few different ways, but keep getting an error.

data want;

set have;

If age_pdts= 2 <= Patage <= 13 then drop;

run;

Here is the freq table...

age_pdts Frequency Percent Cumulative
Frequency
Cumulative
Percent
1 3344 1.09 3344 1.09
2 20102 6.57 23446 7.66
3 24131 7.89 47577 15.55
4 28807 9.41 76384 24.96
5 34800 11.37 111184 36.33
6 35643 11.65 146827 47.98
7 31945 10.44 178772 58.42
8 29255 9.56 208027 67.98
9 25267 8.26 233294 76.24
10 22271 7.28 255565 83.52
11 19398 6.34 274963 89.86
12 16556 5.41 291519 95.27
13 12930 4.23 304449 99.49
14 1543 0.50 305992 100.00
28 7 0.00 305999

100.00

Accepted Solutions
Solution
‎11-10-2015 01:02 PM
Super User
Posts: 23,683

## Re: selecting certain age observations

You want to keep them if you're creating a subset to look at.

if age_pdts<=2 OR Age_pdts>=13 then output;

All Replies
Solution
‎11-10-2015 01:02 PM
Super User
Posts: 23,683

## Re: selecting certain age observations

You want to keep them if you're creating a subset to look at.

if age_pdts<=2 OR Age_pdts>=13 then output;
Regular Contributor
Posts: 182

## Re: selecting certain age observations

Always seems so easy when you do it!! lol

Valued Guide
Posts: 863

## Re: selecting certain age observations

There's several ways to do this, here's another idea:

set have;
if 2 <= age_pdts <= 13 then output good;