## Adding another row based on conditions

Solved
Occasional Contributor
Posts: 15

# Adding another row based on conditions

I want to add another row based on the value.

In the data below, for the first observation, for example, for firm 1, starting from 15-JAN-2012, for every 12 month, for 3 times, I need to give \$1000. For observation 4, for firm 2, starting from 05-FEB-2015, every 6 month, for two times, I need to give firm \$1000. (I just put two firms for brevity)

`data schedule; input firmid startdate mmddyy10. unit times amount; datalines;1 01/15/2012 12 3 10001 03/15/2013 12 1 20001 01/30/2011 3 4 5002 02/05/2015 6 2 1000;run;proc print data=schedule;format startdate date11.;run;`

In the end, I need a table that looks like below

Thanks!

Accepted Solutions
Solution
‎02-23-2017 09:53 PM
Super Contributor
Posts: 260

## Re: Adding another row based on conditions

Here you go:

``````data schedule;
input firmid startdate mmddyy10. unit times amount;
attrib startdate length=4 format=date9.;
datalines;
1 01/15/2012 12 3 1000
1 03/15/2013 12 1 2000
1 01/30/2011 3 4 500
2 02/05/2015 6 2 1000
;
run;

data want;
set schedule;
output;
do i = 1 to times - 1;
startdate = intnx('month', startdate, unit, 's');
output;
end;
keep firmid startdate amount;
run;``````

All Replies
Solution
‎02-23-2017 09:53 PM
Super Contributor
Posts: 260

## Re: Adding another row based on conditions

Here you go:

``````data schedule;
input firmid startdate mmddyy10. unit times amount;
attrib startdate length=4 format=date9.;
datalines;
1 01/15/2012 12 3 1000
1 03/15/2013 12 1 2000
1 01/30/2011 3 4 500
2 02/05/2015 6 2 1000
;
run;

data want;
set schedule;
output;
do i = 1 to times - 1;
startdate = intnx('month', startdate, unit, 's');
output;
end;
keep firmid startdate amount;
run;``````
Occasional Contributor
Posts: 15

## Re: Adding another row based on conditions

It works great! Thank you so much.
☑ This topic is solved.