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

st: Counting and eliminating repeated rows from data set


From   "Jose Passos" <[email protected]>
To   <[email protected]>
Subject   st: Counting and eliminating repeated rows from data set
Date   Mon, 25 Jul 2005 18:59:19 +0100

Hi all,
Suppose I had data like this:

x1  x2  x3  x4 x5  d
19   8  20   0  1 10
80   5  23   1  0 12
80   5  23   1  0  0
80   5  23   1  0  0
81   2  21   1  1 50
82   4  19   0  0  5
82   4  19   0  0  0
87   6  29   0  1  5
...

I want to reshape the data set, eliminating repeated rows and creating a new
variable (nd) that counts the repeated rows (e.g. rows 2-4 and rows 6-7,
above) so it looks like this:

x1  x2  x3  x4 x5  d  nd
19   8  20   0  1 10   1
80   5  23   1  1 12   3
81   2  21   1  1 50   1
82   4  19   0  0  5   2
87   6  29   0  1  5   1
...

Thank you in advance
jose

*
*   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