BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

Sex

Age

F

13

F

13

F

14

F

12

F

15

F

11

F

14

F

12

F

15

M

14

M

14

M

12

M

13

M

12

M

16

M

12

M

15

M

11

M

15

i have above dataset how derive extra record for maximum age like see below dataset 

Sex

Age

status

F

11

 

F

12

 

F

12

 

F

13

 

F

13

 

F

14

 

F

14

 

F

15

 

F

15

 

F

15

maximum

M

11

 

M

12

 

M

12

 

M

12

 

M

13

 

M

14

 

M

14

 

M

15

 

M

15

 

M

16

 

M

16

maximum

5 REPLIES 5
singhsahab
Lapis Lazuli | Level 10

Hello,

 

data have;
input Sex $ Age;
datalines;
F 13
F 13
F 14
F 12
F 15
F 11
F 14
F 12
F 15
M 14
M 14
M 12
M 13
M 12
M 16
M 12
M 15
M 11
M 15
;
run;

proc sort ; by sex age;
run;

data want;
set have;
by sex age;
if last.sex then status='maximum';
run;

 

 

Thanks,

 

thanikondharish
Fluorite | Level 6
i wrote program like this but i want to write code use (do until) within
datastep block
singhsahab
Lapis Lazuli | Level 10

Hello,

 

If a simple salutation is available ,Why you want to make it complex by using loops . if you use explicit loop , it'll take so more time then implicit loop. 

 

Meanwhile you can use Array to fulfill yr request . 

 

Thanks... 

PeterClemmensen
Tourmaline | Level 20
Why on Earth Do you want to arramge your data like this?

If there is a reporting purpose behind, then perhaps PROC REPORT is a better approach

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
  • 5 replies
  • 1368 views
  • 4 likes
  • 4 in conversation