Dear All
Code:
input str1 firm float(sales) int year
"a" . 2010
"a" . 2011
"a" 5 2012
"b" 6 2010
"b" 7 2011
"b" 8 2012
end
This is a sample dataset. Based on the sample dataset,first I would like to create group called pre-regulation(year 2010 & 2011) & post regulation(year 2012 & 2013). Then I would like to tell Stata to count the no: of times a firm reported sales during the pre-regulation period and keep it as dummy . For instance, in my example, during the pre-regulation period(2010-2011) firm "a" didnt report any sales whereas firm "b" reported sales during the year 2010& 2011(hence 2 times) . Thus "b" should be given a dummy. I tried egen salescount= count( sales), by(id ), but that will not be helpful in my case, since that counting ignores the period effect

Here are the codes I tried
Code:
encode firm,gen(id)
xtset id year
gen pre_reg=1 if year <2012
gen post_reg=1 if year >2011
egen salescount = count( sales), by(id )         // gives count by id only and ignores year
egen salescount2 = count( sales ), by(id  & pre_reg==1  )           // will not work, but I want some thing similar
Am I making sense?If yes I request members to help me