Code:
input float(id wave year income) 101 200901 2009 1500 101 200902 2009 1500 101 200903 2009 1500 101 200904 2009 1500 101 200905 2009 1500 101 200906 2009 1500 101 200907 2009 1500 101 200908 2009 1500 101 200909 2009 1500 101 200910 2009 1500 101 200911 2009 1500 101 200912 2009 1500 101 201001 2010 1800 101 201002 2010 1800 101 201003 2010 1800 101 201004 2010 . 101 201005 2010 1800 101 201006 2010 1800 101 201007 2010 1800 101 201008 2010 . 101 201009 2010 . end
Code:
input float(countyear) 12 12 12 12 12 12 12 12 12 12 12 12 6 6 6 6 6 6 6 6 6
For id 101 in year 2010 the number should be 6 since there are 6 non-missing values of the variable income.
If I do "bys id year: generate countyear = _N" I get value 9 in year 2010. How do I fix this?
Thank you in advance.
0 Response to generate variable with _N but with missing values as wel
Post a Comment