Statalist


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

[no subject]



Place Year Seiz
USA 1980 100
Guam 1980 5
PR 1980 5

I would produce data that looked like this

Country Place Year Seiz
USA USA 1980 100
USA Guam 1980 5
USA PR 1980 5

Then I would do this

preserve
tempfile main
keep if Place==Country
drop Place
rename Seiz SeizMain
sort Country Year
save "`main'", replace
restore

drop if Place==Country
collapse (sum) SeizPlus=Seiz, by(Country Year)
merge Country Year using "`metropolis'"
tab _merge
sort Country Year

browse

At this point I would have a data set with only real countries.
SeizMain would be the number of seizures there, SeizPlus would be the
number of seizures summed up across whatever territories these guys
have. It would be missing (_merge=2) for countries with no overseas
territories.

Is this what you're looking for?

Gabi


On Feb 8, 2008 6:38 PM, Lektzian, David <david.lektzian@ttu.edu> wrote:
> Dear Statlist:
>
> I'm stuck and was hoping somebody could help.  I have data on country,
> country code (ccode), year (1980-2007), and drug seizures.
>
> I want to make a new variable drug seizure plus that adds seizures from
> overseas territories to a country's total.  For example, I have:
>
> Country            code    year   seiz   seizplus
> Britain            200     1980   100      200
> Britain            200     1981   150      300
> .
> .
> .
> US                 2       1980   200      250
> US                 2       1981   250      325
> .
> .
> .
> Brit Virg Isl.       .     1980    50
> Brit Virg Isl.       .     1981    75
> .
> .
> .
> Cayman Isl.       .        1980    50
> Cayman Isl.       .        1981    75
> .
> .
> .
> US Virg Isl.       .       1980    50
> US Virg Isl.       .       1981    75
>
> The country codes are missing for those "countries" that are not really
> countries.  What I want to do is to identify which territories belong to
> which countries and then write a line of code that adds seiz for Britain
> in 1980 to seizures for Brit Virg Isl + Cayman Isl. +....etc for all
> their territories.  Then I would repeat for the US, France, Netherlands,
> etc.  I'm guessing there is an easy way to do this, but I don't know how
> to add two values in the same variable at different years, matching them
> based on a string name and then putting the sum in an additional
> variable.  I have to do this for 8 different types of drug seizures so I
> didn't want to just do it by hand.  After I capture this additional
> seizure data, I will then drop the territories from the analysis as they
> do not match with other variables in the analysis I need to do.
>
> Any help would be greatly appreciated.
>
> Thanks,
> Dave
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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