DATA Step, Macro, Functions and more

DATA Step to create 3 new datasets

Reply
Contributor
Posts: 42

DATA Step to create 3 new datasets

Dear All,

Am having the following fields in a Dataset (Rollnumber, Name,Age, Mark and Dept). Using this , would like to create 3 New Datasets based on Age<20, 20<age>30 and Age ge 30.

Appreciate for the help.

Regards,

S Ravuri.

Frequent Contributor
Posts: 138

DATA Step to create 3 new datasets

data one two three;

set have;

if age < 20 then output one;

if 20< = age <30 then output two;

if age >= 30 then output three;

run;

I have taken into account the equal condition as well. Incase you don't want you can omit.

Respected Advisor
Posts: 3,124

DATA Step to create 3 new datasets

Or more efficiently,

data one two three;

set have;

if age < 20 then output one;

ELSE if 20< = age <30 then output two;

ELSE if age >= 30 then output three;

run;

Regards,

Haikuo

Ask a Question
Discussion stats
  • 2 replies
  • 142 views
  • 0 likes
  • 3 in conversation