BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jenim514
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
You want to keep them if you're creating a subset to look at.

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

View solution in original post

3 REPLIES 3
Reeza
Super User
You want to keep them if you're creating a subset to look at.

if age_pdts<=2 OR Age_pdts>=13 then output;
jenim514
Pyrite | Level 9

Always seems so easy when you do it!! lol

Steelers_In_DC
Barite | Level 11

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

 

data good bad;
set have;
if 2 <= age_pdts <= 13 then output good;
else output bad;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1457 views
  • 2 likes
  • 3 in conversation