I have the following data as specified below where ¨permno” is used as a firm identifier. I need to replace all missing observations of “fyear” with the first forward non-missing observation. That is, for permno 54594 “fyear” should be replaced with “1998” for all observation before fyear==1998 and so on. Please, help me with this issue.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double permno long date double fyear str8 gvkey 54594 14273 . "001004" 54594 14301 . "001004" 54594 14334 . "001004" 54594 14364 . "001004" 54594 14392 1998 "001004" 54594 14425 . "001004" 54594 14455 . "001004" 54594 14487 . "001004" 54594 14517 . "001004" 54594 14546 . "001004" 54594 14578 . "001004" 54594 14609 . "001004" 54594 14640 . "001004" 54594 14669 . "001004" 54594 14700 . "001004" 54594 14728 . "001004" 54594 14761 1999 "001004" 54594 14791 . "001004" 54594 14822 . "001004" 54594 14853 . "001004" 54594 14882 . "001004" 54594 14914 . "001004" 54594 14944 . "001004" 54594 14973 . "001004" 54594 15006 . "001004" 54594 15034 . "001004" 54594 15064 . "001004" 54594 15095 . "001004" 54594 15126 2000 "001004" 54594 15155 . "001004" 54594 15187 . "001004" 54594 15218 . "001004" 54594 15246 . "001004" 54594 15279 . "001004" 54594 15309 . "001004" 54594 15340 . "001004" 54594 15371 . "001004" 54594 15399 . "001004" 54594 15427 . "001004" 54594 15460 . "001004" 54594 15491 2001 "001004" 14322 14425 . "81238710" 14322 14455 . "81238710" 14322 14487 . "81238710" 14322 14517 . "81238710" 14322 14546 . "81238710" 14322 14578 . "81238710" 14322 14609 1999 "81238710" 14322 14640 . "81238710" 14322 14669 . "81238710" 14322 14700 . "81238710" 14322 14728 . "81238710" 14322 14761 . "81238710" 14322 14791 . "81238710" 14322 14822 . "81238710" 14322 14853 . "81238710" 14322 14882 . "81238710" 14322 14914 . "81238710" 14322 14944 . "81238710" 14322 14973 2000 "81238710" 14322 15006 . "81238710" 14322 15034 . "81238710" 14322 15064 . "81238710" 14322 15095 . "81238710" 14322 15126 . "81238710" 14322 15155 . "81238710" 14322 15187 . "81238710" 14322 15218 . "81238710" 14322 15246 . "81238710" 14322 15279 . "81238710" 14322 15309 . "81238710" 14322 15340 2001 "81238710" 14322 15371 . "81238710" 14322 15399 . "81238710" 14322 15427 . "81238710" 14322 15460 . "81238710" 14322 15491 . "81238710" 14322 15519 . "81238710" 14322 15552 . "81238710" end format %d date
Comment