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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1495 views
  • 4 likes
  • 4 in conversation