Dear readers,
I am currently working with a data set and I would like some of the variables to be extended for a limited number of rows. The data for the moment looks like the following:
Country Year StartingYear EndYear Program Duration Amount
1 1990 . . . . .
1 1991 . . . . .
1 1992 1993 1996 A 3 5000
1 1993 . . . . .
1 1994 . . . . .
1 1995 . . . . .
1 1996 . . . . .
2 1990 . . . . .
2 1991 1991 1995 B 4 6500
2 1992 . . . . .
2 1993 . . . . .
2 1994 . . . . .
2 1995 . . . . .
2 1996 . . . . .
I would like to carry forward the variables StartingYear, EndYear, Program, Duration, Amount so that I will have the information for programs A and B spreading for the whole program duration (3 and 4 in this case), like the following:
Country Year StartingYear EndYear Program Duration Amount
1 1990 . . . . .
1 1991 . . . . .
1 1992 1993 1996 A 3 5000
1 1993 1993 1996 A 3 5000
1 1994 1993 1996 A 3 5000
1 1995 . . . . .
1 1996 . . . . .
2 1990 . . . . .
2 1991 1991 1995 B 4 6500
2 1992 1991 1995 B 4 6500
2 1993 1991 1995 B 4 6500
2 1994 1991 1995 B 4 6500
2 1995 . . . . .
2 1996 . . . . .
I tried to use the carryforward command by typing:
by Country(Year): carryforward StartingYear EndYear Program Duration Amount
which works but carries forward for the whole period (so until 1996) and I couldn't code it such that it carries forward conditional on the duration variable.
Thank you in advance for your help and advice.
Best,
Sandra
I am currently working with a data set and I would like some of the variables to be extended for a limited number of rows. The data for the moment looks like the following:
Country Year StartingYear EndYear Program Duration Amount
1 1990 . . . . .
1 1991 . . . . .
1 1992 1993 1996 A 3 5000
1 1993 . . . . .
1 1994 . . . . .
1 1995 . . . . .
1 1996 . . . . .
2 1990 . . . . .
2 1991 1991 1995 B 4 6500
2 1992 . . . . .
2 1993 . . . . .
2 1994 . . . . .
2 1995 . . . . .
2 1996 . . . . .
I would like to carry forward the variables StartingYear, EndYear, Program, Duration, Amount so that I will have the information for programs A and B spreading for the whole program duration (3 and 4 in this case), like the following:
Country Year StartingYear EndYear Program Duration Amount
1 1990 . . . . .
1 1991 . . . . .
1 1992 1993 1996 A 3 5000
1 1993 1993 1996 A 3 5000
1 1994 1993 1996 A 3 5000
1 1995 . . . . .
1 1996 . . . . .
2 1990 . . . . .
2 1991 1991 1995 B 4 6500
2 1992 1991 1995 B 4 6500
2 1993 1991 1995 B 4 6500
2 1994 1991 1995 B 4 6500
2 1995 . . . . .
2 1996 . . . . .
I tried to use the carryforward command by typing:
by Country(Year): carryforward StartingYear EndYear Program Duration Amount
which works but carries forward for the whole period (so until 1996) and I couldn't code it such that it carries forward conditional on the duration variable.
Thank you in advance for your help and advice.
Best,
Sandra

Comment