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

Please i have a dataset in which i want to keep only people who are aged from 0-5. The data set have list of people up to 17 years but i just want to create a dataset of only kids that are aged 0-5 and for the data-set to retain all the variables. The age variable is is sc_age.

I initially tried using the "where" statement in the larger data step to specify the category but it was not helpful as i will want to run a logistic regression later.

 

Please how do i go about this and any help will be appreciated.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Have you tried to subset the 0-5 age, using where statement, into a separate data-set

to be used for the regression?

data age0_5;
  set have (where=(sc_age le 5); /* or between 0 and 5 - to exclude missing */
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Since I cant see your data, this code is untested.

 

data want;
   set have;
   where age between 0 and 5;
run;
Shmuel
Garnet | Level 18

Have you tried to subset the 0-5 age, using where statement, into a separate data-set

to be used for the regression?

data age0_5;
  set have (where=(sc_age le 5); /* or between 0 and 5 - to exclude missing */
run;

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 914 views
  • 0 likes
  • 3 in conversation