data example;
input firmname $ year revenue;
cards;
MSMFT 2000 323
MSMFT 2001 231
MSMFT 2004 232
MSMFT 2005 152
MSMFT 2006 345
MSMFT 2007 232
MSMFT 2009 231
MSMFT 2010 341
MSMFT 2011 325
NOOTA 1997 232
NOOTA 1998 212
NOOTA 1999 231
NOOTA 2000 405
NOOTA 2001 525
NOOTA 2002 251
NOOTA 2004 231
NOOTA 2005 550
NOOTA 2006 124
NOOTA 2007 235
NOOTA 2013 952
NOOTA 2014 532
run; Hi. I posted a question regarding how to assign a dummy variable for the existence of row information in three in a row, and related to that question, I am also wondering how to assign a dummy variable for checking whether three row information out of four previous rows exist or not. To be specific, as shown in the example data above, if the MSMFT's revenue information for 2006, 2007, 2009 exists, but missing for 2008, so the dummy variable for the existence of revenue information in three-year in a row should be zero, but the dummy variable that I would like to generate should be one, in that, for 2009, two out of three previous years' revenue information (e.g. 2006 and 2007) exist along with the revenue information for 2009. Likewise, for 2010, two out of three previous years' revenue information (e.g. 2007 and 2009) exist along with the revenue information for 2010, so the dummy variable that I would like to generate should be given one. The final output from the example case should look like below. Thank you in advance! firmname year revenue three_row three_four MSMFT 2000 323 0 0 MSMFT 2001 231 0 0 MSMFT 2004 232 0 0 MSMFT 2005 152 0 0 MSMFT 2006 345 1 1 MSMFT 2007 232 1 1 MSMFT 2009 231 0 1 MSMFT 2010 341 0 1 MSMFT 2011 325 1 1 NOOTA 1997 232 0 0 NOOTA 1998 212 0 0 NOOTA 1999 231 1 1 NOOTA 2000 405 1 1 NOOTA 2001 525 1 1 NOOTA 2002 251 1 1 NOOTA 2004 231 0 1 NOOTA 2005 550 0 1 NOOTA 2006 124 1 1 NOOTA 2007 235 1 1 NOOTA 2013 952 0 0 NOOTA 2014 532 0 0
... View more