Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Keep observations in 1/100 by country and year
From
Estrella Gomez <[email protected]>
To
[email protected]
Subject
st: Keep observations in 1/100 by country and year
Date
Tue, 7 May 2013 16:49:39 +0200
Hi, statalisters
I have a dataset with songs by year and country. I would like to keep
only the top 100 songs for each country each year (there are 18
countries and 6 years). I have tried the following:
gsort country year -tot_sales
*because I want the songs with higher number of sales
gen top100=0
bysort country year: replace top100=1 in 1/100
*to generate a dummy that takes value one for the top 100 songs, so I
can drop observations that equals zero
However, Stata says that it's not possible to combine "by" with "in"
Any idea?
Thanks a lot,
Estrella
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/