Dear All,

I have the following data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
country ISO3N YEAR BEGINrrs BEGINrrs_3
"Afghanistan" 4 1800 . .
"Afghanistan" 4 1801 . .
"Afghanistan" 4 1802 1 .
"Afghanistan" 4 1803 . .
"Afghanistan" 4 1804 . .
"Afghanistan" 4 1805 . .
"Afghanistan" 4 1806 . .
"Afghanistan" 4 1807 . .
"Afghanistan" 4 1808 . .
"Afghanistan" 4 1809 . .
"Afghanistan" 4 1810 . .
"Afghanistan" 4 1811 . .
"Afghanistan" 4 1812 . .
"Afghanistan" 4 1813 . .
"Afghanistan" 4 1814 1 .
"Afghanistan" 4 1815 . .
"Afghanistan" 4 1816 . .
"Afghanistan" 4 1817 . .
"Afghanistan" 4 1818 . .
end
I am trying to replace BEGINrrs_3=1 when BEGINrrs==1 and for the following 3 years, since I want to have a 3-year post-event clearly pointed out by this dummy.
For instance, BEGINrrs_3 should be equal to 1 in 1802 and the following 3 years: 1803, 1804, 1805.

I have tried using both replace playing with [_n] and [_n-1] weights and carryforward (to be installed from SSC), but I can't figure out how to limit these commands for my 3-year time window.

I would really appreciate your help.
Many thanks!

Best
Giovanni