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

I have a large dataset where each rate is the same for all ages between age_first and age_last. Below is an example of one row of the dataset:

 

age_first   age_last   rate

   15             20         4.16

 

My goal is to convert this row into many, with one row for each age, like so:

 

age   rate

15     4.16

16     4.16

17     4.16

18     4.16

19     4.16

20     4.16

1 ACCEPTED SOLUTION
2 REPLIES 2
Reeza
Super User

Use those values as the do loop start and stop.

 

data want;
set have;

do age=age_first to age_list;
       output; *writes a record for each age;
end;

run;

@rav31 wrote:

I have a large dataset where each rate is the same for all ages between age_first and age_last. Below is an example of one row of the dataset:

 

age_first   age_last   rate

   15             20         4.16

 

My goal is to convert this row into many, with one row for each age, like so:

 

age   rate

15     4.16

16     4.16

17     4.16

18     4.16

19     4.16

20     4.16


 

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

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1186 views
  • 2 likes
  • 3 in conversation