Hi there,
for each observation for which the variable selected==1,I want to create a variable that is =1 if, by firmid, there is at least another observation for which the variables typetextdef==1 & nao_t==0 that has an older date and that date is before 31 December 2010, =2 if by firm id, there is at least another observation for which the variables typetextdef==1 & nao_t==0 that has a older date and that date is after 1st of Jan 2011, and =3 if by firm id, there are at least two observations for which the variables typetextdef==1 & nao_t==0 that have older dates, and these dates are one before 31 December 2010 and the other is after 1st of Jan 2011.
So with the example below, for firmid "00708002100012" the variable should be 2, for firmid "01545059600026" it should be 2, for firmid "06150024500016" it should be 1, for firmid "06220100900222" it should be 3 and so on
I hope it is clear.
Thank you,
Ylenia
for each observation for which the variable selected==1,I want to create a variable that is =1 if, by firmid, there is at least another observation for which the variables typetextdef==1 & nao_t==0 that has an older date and that date is before 31 December 2010, =2 if by firm id, there is at least another observation for which the variables typetextdef==1 & nao_t==0 that has a older date and that date is after 1st of Jan 2011, and =3 if by firm id, there are at least two observations for which the variables typetextdef==1 & nao_t==0 that have older dates, and these dates are one before 31 December 2010 and the other is after 1st of Jan 2011.
So with the example below, for firmid "00708002100012" the variable should be 2, for firmid "01545059600026" it should be 2, for firmid "06150024500016" it should be 1, for firmid "06220100900222" it should be 3 and so on
I hope it is clear.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float selected str14 firmid str8 date float(typetextdef nao_t) 1 "00705004000018" "20151023" 1 0 1 "00708002100012" "20141224" 1 0 0 "00708002100012" "20121005" 1 0 0 "00708002100012" "20111202" 1 0 0 "00708002100012" "20110705" 4 1 0 "00708002100012" "20090706" 4 1 1 "01545059600026" "20160307" 1 1 0 "01545059600026" "20130926" 1 0 1 "01585179300131" "20160407" 1 1 0 "01585179300131" "20140115" 1 1 0 "01585179300131" "20120628" 1 0 1 "01625002900739" "20120627" 1 0 0 "01625002900739" "20090317" 1 0 0 "01625002900739" "20070514" 1 1 1 "01698006200018" "20111201" 1 1 0 "01698006200018" "20100203" 1 1 1 "03652015300028" "20160921" 6 0 0 "03652015300028" "20150703" 6 0 1 "04705017400029" "20160802" 1 0 1 "05480095800248" "20160520" 6 0 0 "05480095800248" "20151023" 6 0 0 "05480095800248" "20140213" 1 1 1 "05480095800503" "20160520" 6 0 0 "05480095800503" "20151023" 6 0 0 "05480095800503" "20140213" 1 1 1 "05480654200012" "20160421" 1 0 0 "05480654200012" "20160421" 1 0 0 "05480654200012" "20150203" 1 1 0 "05480654200012" "20130403" 4 1 0 "05480654200012" "20121019" 7 0 0 "05480654200012" "20120320" 1 0 1 "05480654203602" "20160421" 1 0 0 "05480654203602" "20160421" 1 0 0 "05480654203602" "20150203" 1 1 0 "05480654203602" "20130403" 4 1 0 "05480654203602" "20121019" 7 0 0 "05480654203602" "20120320" 1 0 1 "05550190200039" "20160325" 1 1 0 "05550190200039" "20150402" 1 1 0 "05550190200039" "20140409" 1 1 0 "05550190200039" "20110331" 1 1 0 "05550190200039" "20090416" 4 1 1 "05580925500015" "20160627" 6 0 0 "05580925500015" "20150401" 6 0 1 "05650171100115" "20131219" 1 0 0 "05650171100115" "20120719" 1 0 0 "05650171100115" "20081218" 1 1 1 "05680065901435" "20161208" 1 0 0 "05680065901435" "20121205" 1 0 0 "05680065901435" "20090115" 1 1 0 "05680065901435" "20070130" 1 1 1 "05720137800023" "20150527" 1 1 0 "05720137800023" "20141010" 6 0 0 "05720137800023" "20120612" 1 1 0 "05720137800023" "20110407" 1 1 1 "05750274200661" "20111223" 1 1 0 "05750274200661" "20111223" 1 0 0 "05750274200661" "20110523" 1 1 1 "05780615000017" "20140127" 1 0 1 "05820018900015" "20131209" 1 0 0 "05820018900015" "20110330" 1 1 0 "05820018900015" "20090708" 1 1 1 "05980406200053" "20150925" 1 0 0 "05980406200053" "20120713" 1 0 1 "06020012800019" "20111219" 1 0 0 "06020012800019" "20100218" 1 1 1 "06080139600023" "20121127" 1 0 1 "06150024500016" "20161222" 1 0 0 "06150024500016" "20161222" 1 0 0 "06150024500016" "20160513" 1 1 0 "06150024500016" "20140228" 1 1 0 "06150024500016" "20130306" 1 1 0 "06150024500016" "20120330" 1 1 0 "06150024500016" "20110414" 1 1 0 "06150024500016" "20070713" 1 0 0 "06220100900222" "20161214" 7 0 1 "06220100900222" "20151216" 1 1 0 "06220100900222" "20141219" 1 0 0 "06220100900222" "20140117" 1 1 0 "06220100900222" "20140117" 1 1 0 "06220100900222" "20140117" 1 1 0 "06220100900222" "20131219" 1 1 0 "06220100900222" "20130118" 1 1 0 "06220100900222" "20130118" 1 1 0 "06220100900222" "20130118" 1 1 0 "06220100900222" "20130118" 1 1 0 "06220100900222" "20130118" 1 1 0 "06220100900222" "20120111" 1 1 0 "06220100900222" "20120111" 1 1 0 "06220100900222" "20120111" 1 1 0 "06220100900222" "20120111" 1 1 0 "06220100900222" "20111215" 1 0 0 "06220100900222" "20100113" 1 0 end
Thank you,
Ylenia
Comment