Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: gen a newvar


From   "Hans J. Baumgartner" <[email protected]>
To   [email protected]
Subject   st: gen a newvar
Date   Mon, 14 Mar 2005 18:15:26 +0100

Dear Statalist,

this may sound like a very silly question. But I seem to be unable to solve it anyway.


My data looks like this:

id x
1 5
1 5
1 10
1 10
1 21
1 21
1 21
2 ...

I want to generate a newvar with the maximum value of x , which is _N. But if the difference between the largest and the second largest value is <=7, newvar should take the value of the second largest value of x.

Any suggestions on this?

Cheers
Hans

--
Hans J. Baumgartner DIW Berlin
German Institute for Economic Research
Dept. Public Economics
K�nigin-Luise-Str. 5; 14195 Berlin; Germany
Tel.: +49/30/89789-307
Fax.: +49/30/89789-114
http://www.diw.de
http://www.hansbaumgartner.de



*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index