Hello Everyone
I have panel data, which looks like the following:
I am trying to use the following code to generate a dummy
In plain English, I am trying to see, whether there is the same value of "sellD" for the same text of "securitydescription" for the same "directorid" in the last three years in the same month.
But the code does not work. Stata reports "not sorted". I know Stata may not be able to handle two cross-section ids, but what is the most efficient way to achieve the same effect?
I have panel data, which looks like the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long directorid str16 securitydescription float(date sellD) 2009 "Com" 462 0 2009 "Com" 527 1 2009 "Com" 532 1 2009 "Com" 559 0 2010 "Com" 462 0 2010 "Com" 577 1 2010 "Com" 578 1 2163 "Com" 672 0 3688 "Com" 545 1 3688 "Com" 550 1 3689 "Com" 399 0 3689 "Com" 400 0 3689 "Com" 405 0 3689 "Com" 410 0 3689 "Com" 438 0 3689 "Com" 440 0 3689 "Com" 447 0 3689 "Com" 450 0 3689 "Com" 459 0 3689 "Com" 480 0 3689 "Com" 481 0 3689 "Com" 490 0 3689 "Com" 493 0 3689 "Com" 502 0 3689 "Com" 504 0 3689 "Com" 505 0 3689 "Com" 510 0 3689 "Com" 512 0 3689 "Com" 516 0 3689 "Com B" 526 0 end format %tm date
Code:
bys directorid securitydescription date : gen D=1 if sellD==1&L12.sellD==1&L24.sellD==1&l48.sellD==1
But the code does not work. Stata reports "not sorted". I know Stata may not be able to handle two cross-section ids, but what is the most efficient way to achieve the same effect?
Comment