Hi,
I want to sum the unique identifier in my data (id) over the panel variables ( county and year ).
However, there are some repeated observations of my unique identifier ( id) which I have put it in bold form.
After getting rid of this repeated observation , I can go ahead with summing over the panel variable. I've shown my thought out steps of doing so.
Do you think this is the right approach to address the issue or my intended goal ?
My approach of doing is going to be ( I have not done it yet)
----------------------- copy starting from the next line -----------------------
I want to sum the unique identifier in my data (id) over the panel variables ( county and year ).
However, there are some repeated observations of my unique identifier ( id) which I have put it in bold form.
After getting rid of this repeated observation , I can go ahead with summing over the panel variable. I've shown my thought out steps of doing so.
Do you think this is the right approach to address the issue or my intended goal ?
My approach of doing is going to be ( I have not done it yet)
Code:
bysort county year id : gen wanted = _n == 1 by county year : replace wanted = sum(wanted) by county year : replace wanted = wanted[_N]
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double id float(county sd3_date year) 20010000001 6001 14943 2000 20010000001 17031 14943 2000 20010000003 46135 14945 2000 20010000004 48303 14943 2000 20010000005 34021 14945 2000 20010000005 6059 14945 2000 20010000005 34023 14945 2000 20010000005 34021 14945 2000 20010000005 34021 14945 2000 20010000009 55139 14943 2000 20010000012 41051 14943 2000 20010000018 6085 14945 2000 20010000018 6085 14945 2000 20010000019 42045 14943 2000 20010000019 34025 14943 2000 20010000020 6085 14943 2000 20010000020 6085 14943 2000 20010000020 6081 14943 2000 20010000020 6085 14943 2000 20010000020 6085 14943 2000 20010000020 6001 14943 2000 20010000025 6041 14945 2000 20010000025 6041 14945 2000 20010000025 6085 14945 2000 20010000025 6085 14945 2000 20010000025 6085 14945 2000 end format %td sd3_date
Comment