Statalist The Stata Listserver


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

Re: st: Generate question


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: Generate question
Date   Fri, 27 Apr 2007 07:08:39 -0400

Right, I was thinking x was numeric, so the missings
went to the bottom.

Nick Cox wrote:
I am not following this closely, but it may be that

bysort y (x) : replace x = x[_N]
is what you want.
gsort y - x
by y : replace x = x[1]
is a long-winded equivalent.
Nick [email protected]
Hendri Adriaens

This should do it:

  bys y (x): replace x=x[1]
Unfortunately not. Because the sorting brings the empty opnes to the top,
all the matching x's are replaced by the empty (missing) string, which makes
me loose more data. I tried doing it with a gsort before the by command:

gsort y -x

But then

by y (x): replace x=x[1]

Complains r(5): not sorted. Is there another way?
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index