sort the input12dataset .First by number in ascending and second by income in descending order.Using input12 dataset with by group processing create test data from the input12 dataset
test 2 dataset must contain only one observation with highest income from each group of distint number value
MY CODE:
proc sort data=input12 out=test;
by number descending income;
run;
data test;
set test;
by number;
if first.number;
run;
Works, but I would specify the sorting order in want to make sure
data have;
infile datalines;
input number income;
datalines;
1 100
1 130
1 120
1 110
2 250
2 200
3 300
4 420
4 410
4 430
4 440
4 450
5 530
5 520
5 510
5 500
8 800
;
run;
proc sort data=have out=haves;
by number descending income;
run;
data want;
set haves;
by number descending income;
if first.number;
run;
- Cheers -
Works, but I would specify the sorting order in want to make sure
data have;
infile datalines;
input number income;
datalines;
1 100
1 130
1 120
1 110
2 250
2 200
3 300
4 420
4 410
4 430
4 440
4 450
5 530
5 520
5 510
5 500
8 800
;
run;
proc sort data=have out=haves;
by number descending income;
run;
data want;
set haves;
by number descending income;
if first.number;
run;
- Cheers -
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.