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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11

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 -

View solution in original post

1 REPLY 1
Oligolas
Barite | Level 11

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 -

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 334 views
  • 0 likes
  • 2 in conversation