Stata: sales growth rate of multiple groups -


cross-posting: german: http://www.stata-forum.de/post1716.html#p1716 english: http://www.talkstats.com/showthread.php/47299-sales-growth-rate-with-multiple-groups-conditions

i want calculate annual sales growth rate of different firm-groups in stata. firms grouped variables country , industry.

i summed sales each group (called sales_total: sales of firms in group equal country, industry , year):

bysort country year industry: egen sales_total = sum(sales) 

i have bigger sample, tried calculate growth-rate smaller sample.

i tried multiple combinations such as:

egen group = group(year country industry) xtset group year, yearly bys group: g salesgrowth = log(d.sales_total) 

or

bysort group: gen salesgrowth=(sales[_n]-sales[_n-1])/sales[_n-1]* 

also tsset.

and tried answer: generate percent change between annual observations in stata?

but error messages such

  repeated time values within panel  

or

 repeated time values within sample 

due repetition of number in variable such group.

can me find yearly growth rate each group (firms same country & industry)?

update

here again example of observations (which have 10,000 firms on 10 years). there missing values (for sales, industry, year, country)

firms -- country -- year -- industry -- sales

-a --------usa-------1----------1----------300

-a---------usa-------2----------1--------4000

-b---------ger-------1----------1--------200

-b---------ger-------2----------1--------400

-c---------usa------1----------1----------100

-c---------usa------2----------1----------300

-d---------usa------1----------1----------400

-d---------usa------2----------1----------200

-e---------usa------1----------1----------7000

-e---------usa------2----------1----------900

-f----------ger------1----------2----------100

-f---------ger------2----------2----------700

-h---------ger------1----------2----------700

-h---------ger------2----------2----------600

-.................etc.....................................

i tried programing mentioned, got couple of variables need used in same row , not in same column (which need). there possibility keep data without reshaping, keeping them in row, example grouping observations:

egen group=group(industry year country)

and try

xtset group year bysort group: sales_growth = log(d.sales) or bysort group: gen sales_growth = (sales[_n]-sales[_n-1])/sales[_n-1]

thank you!

the strategy here trying work @ wrong level of resolution. should

collapse (sum) sales, by(country year industry)  

and work reduced dataset. depending on want precisely, need restructure data reshape different industries give different variables.

xtset country year  

and growth rates easier calculate.


Comments