I am trying to fill up the missing string variable. The current data is:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str2 nation float(mktcap comp_id year) "CA" 66.99689 11056 2000 "CA" 10.21328 11056 2001 "CA" 19.3281 11056 2002 "" 6.319495 11057 2000 "" 19.34623 11057 2001 "CA" 8.470743 11057 2002 "CA" 51.13004 11058 2000 "CA" 61.17423 11058 2001 "ZA" 95.96128 11059 2000 "ZA" 225.55865 11059 2001 "ZA" 701.4942 11059 2002 "IL" 166.84026 11060 2000 "IL" 113.6493 11060 2001 "IL" 71.14658 11060 2002 "CL" 3301.76 11061 2000 "CL" 2219.68 11061 2001 "CL" 680.1124 11061 2002 "" 9.246715 11062 2000 "CA" 17.92385 11062 2001 "CA" 21.14309 11062 2002 "" 2.325993 11063 2000 "HK" 2.059 11063 2001 "" 1.885 11063 2002 "" 6.306048 11064 2000 "AU" 4.389617 11064 2001 "AU" 1.9777976 11064 2002 "AT" . 11065 2000 "" .54666144 11065 2001 "" 1.06623 11065 2002 "AU" 134.85013 11066 2000 "AU" 156.21486 11066 2001 "AU" 180.5218 11066 2002 "CA" 6904.636 11067 2000 "CA" 6425.909 11067 2001 "CA" 8189.106 11067 2002 "" . 11068 2001 "JP" . 11068 2002 "BR" 23.197685 11069 2000 "BR" 21.755056 11069 2001 "BR" 39.87131 11069 2002 "FR" 95.75793 11070 2000 "FR" 50.84423 11070 2001 "FR" 24.417324 11070 2002 "TH" 46.915 11071 2000 "TH" 53.2272 11071 2001 "TH" 154.6489 11071 2002 "" . 11072 2000 "" . 11072 2001 "GB" 6.2909 11072 2002 "GB" 3807.442 11073 2000 "GB" 3592.452 11073 2001 "GB" 3842.6235 11073 2002 end
The nation (string variable) is missing for some companies. For example, "nation variable" is missing for "comp_id=11057" in year 2000 to 2001. However, based on year 2002, I can say that the nation should be CA. Additionally, "nation variable" is missing for "comp_id=11063" in year 2002. But, again, based on year 2001, the nation should be "HK."
The full data has more than 40 nations, from 2000 to 2017, with 68105 different companies. So, it is impossible for me to fill up the missing nation manually.
Your help would be greatly appreciated.
Thanks a lot.
0 Response to Fill up missing string variable
Post a Comment