Marta wrote:
...
"Cars" is a string variable under which I have
different car models. The second variable is "Price".
I have different prices for the same car model.
What I need to do is to sort ascendingly the prices
of each car model, because I only want to keep the
lowest price of each car model. I tried to use the
commands -sort- and -by-, but I didn't succeed.
Suppose my dataset is
CAR PRICE
Renault Clio 10000
Renault Clio 11000
Renault Clio 10500
Audi A4 30000
Audi A4 27000
Audi A4 28000
First I want to arrange the dat in this way
CAR PRICE
Renault Clio 10000
Renault Clio 10500
Renault Clio 11000
Audi A4 27000
Audi A4 28000
Audi A4 30000
and then I only want to keep the first observation of each category
CAR PRICE
Renault Clio 10000
Audi A4 27000
--------------------------------------------
sort CAR PRICE
by CAR: keep if _n==1
Hope this helps
Svend
________________________________________________________
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C, Denmark
Phone, work: +45 8942 6090
Phone, home: +45 8693 7796
Fax: +45 8613 1580
E-mail: [email protected]
_________________________________________________________
*
* 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/