Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: generating new observations

From   David Kantor <>
Subject   Re: st: generating new observations
Date   Wed, 29 Mar 2006 12:57:51 -0500

At 12:45 PM 3/29/2006, Kremena wrote:

I have a data set with the following variables:

importer     exporter     commoditycode   tradevalue

Belgium      Argentina    1               123
Belgium      Argentina    2               456
Luxemburg    Argentina    1               789
Luxembourg   Argentina    3               147

I want to generate new observations such that importer is Belgium-Luxembourg
and tradevalue is the combined trade value for the two countries for the
respective commodity.

Can someone tell me how I can do that?
You can do...

collapse (sum) tradevalue , by(commoditycode)

This will sum to the level of commoditycode, regardless of importer or exporter (and it won't create a combined importer identifier). If you want specific groups of importers or importer/exporter combinations, you will need to do that in advance, creating another variable, and then put that variable into the by() option.

Good luck.

* For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index