so, I have a problem constructing two variables. I briefly describe my data here below: the database consists of a series of firms making products through molecules. So to each firm can belong different products using different molecules each one. The variable data_lancio describes the launch date of the product and of the associated molecule, while the variable Year represents the year in which the other variables (not displayed in the data) are available. The dataex his here represented:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(idfirm idproduct) float(id_molecule Year) int data_lancio 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2013 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2014 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 287 1104 2015 2013 1 1474 895 2013 2013 1 1474 895 2013 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2014 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 1474 895 2015 2013 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2014 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3026 301 2015 2014 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2008 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2009 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 1 3051 301 2010 2008 end
Code:
bysort id_molecule (Year): gen counter_new_marke =_n == 1 // questa dovrebbe essere per new to the market bysort idfirm id_molecule (idpr Year) : gen counter_new_fir = _n == 1 //questa dvrebbe essere per new_to the firm
Code:
collapse (sum) salesmnf counter_new_fir counter_new_marke (min) anno_numeric data_lancio (first) id_molecule firstposition molecule atc4 crp prd internationalp seq (last) sequence ,by (idfirm idprod Year)
Code:
collapse (mean) avsales avsales_existing avsales_new (first) agepr molecule idprod salesmnf data_lancio anno_numeric firstpos atc4 crp prd internationalp (max) numero_nuovi, by(idfirm Year)
0 Response to Variable generation
Post a Comment