My data has multiple observations per id. There are two examination times: examdate and injedtdate. I want to create a new variable to indicate '1' where examdate=injectdate in same id, and otherwise '0' where examdate in not equal injectdate in same id.
Can someone please suggest a looping code I can apply to achieve this. An example data is below. Thanks
Can someone please suggest a looping code I can apply to achieve this. An example data is below. Thanks
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id float(examdate injectdate) 101 19079 19075 101 19050 19045 101 19079 19063 101 19050 19039 102 19044 19019 102 19072 19044 102 19072 19059 103 19001 18997 103 19127 19085 104 19127 19106 104 19037 19032 105 19114 19051 105 19051 19024 105 19051 18997 107 19127 19072 107 19127 19106 108 19037 19023 110 19116 19085 110 19157 19120 110 19157 19116 end format %tdDD_Mon_CCYY examdate format %tdDD_Mon_CCYY injectdate
Comment