BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Fluorite | Level 6

## Create a numeric list with end value determined by another variable

Hi all,

I have a problem creating a variable that I think can be solved using some sort of loop but I don't know how to code it. I have an input dataset with information about mortgages, including the maturity for each one. I need to create a variable called year, that creates a line for each year from 0 to maturity for each contract. Therefore, the output dataset will have as many lines as contracts times (maturity +1, accounting for the zeroes). Below I set an example of my input and my expected output, so that it is easier to understand:

Input

 CONTRACT_ID PD INDUSTRY MATURITY 13000 0,45 construction 3 12400 0,09 retail 5 37000 0,023 tech 2

Desired output

 CONTRACT_ID PD INDUSTRY MATURITY YEAR 13000 0,45 construction 3 0 13000 0,45 construction 3 1 13000 0,45 construction 3 2 13000 0,45 construction 3 3 12400 0,09 retail 5 0 12400 0,09 retail 5 1 12400 0,09 retail 5 2 12400 0,09 retail 5 3 12400 0,09 retail 5 4 12400 0,09 retail 5 5 37000 0,023 tech 2 0 37000 0,023 tech 2 1 37000 0,023 tech 2 2
1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: Create a numeric list with end value determined by another variable

``````data want;
set have;
do year=0 to maturity;
output;
end;
run;``````
--
Paige Miller
2 REPLIES 2
Diamond | Level 26

## Re: Create a numeric list with end value determined by another variable

``````data want;
set have;
do year=0 to maturity;
output;
end;
run;``````
--
Paige Miller
Fluorite | Level 6

## Re: Create a numeric list with end value determined by another variable

This has worked perfectly, thank you so much for your time!
Discussion stats
• 2 replies
• 263 views
• 1 like
• 2 in conversation