Hi all,
I'm trying to create a dummy that takes a value of 1 when the owner of a company is also a company in the database for that given year.
I have provided an example of the database below.
I thus need a dummy to take the value of 1 in observation 2 and 4. I have tried the following without any succes:
But this only looks per observation if the owner and company are equal.
This does the same I think.
Hope somebody can help me.
Many thanks in advance!
Best,
Niels
I'm trying to create a dummy that takes a value of 1 when the owner of a company is also a company in the database for that given year.
I have provided an example of the database below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(year company owner) 1 1 . 1 2 . 1 3 2 2 1 . 2 2 . 2 4 1 3 1 . 3 2 . 3 4 . end
Code:
sort year company by year: gen dummy=1 if company==owner
Code:
sort year company by year: gen dummy=1 if inlist(company, owner)
Code:
sort year company by year: gen dummy=1 if inlist(company, owner[_n]/owner[_N])
Hope somebody can help me.
Many thanks in advance!
Best,
Niels
Comment