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]

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Count the number of observation of the same kind |

Date |
Sat, 24 Apr 2010 16:14:53 +0200 |

<> " You can use bys Y:gen X=_N" Very true! Abhimanyu`s solution is preferable just in case George has missings in there which he wants to -count- as well. See this comparison: ******* clear* inp byte Y 8 8 5 5 5 3 1 1 1 1 . . . end gen byte myorder=_n bys Y: egen byte X=count(Y) bys Y:gen byte Xalt=_N //reestablish previous order, if important sort myorder drop myorder list, noo sepby(Y) ******* HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Abhimanyu Arora Sent: Samstag, 24. April 2010 16:10 To: statalist@hsphsun2.harvard.edu Subject: st: RE: Count the number of observation of the same kind You can use bys Y:gen X=_N Abhimanyu -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of George Chioran Sent: zaterdag 24 april 2010 16:05 To: statalist@hsphsun2.harvard.edu Subject: st: Count the number of observation of the same kind Dear statalisters, This may be a basic question, but how can you create a variable X in which there we have the sum of the observations of the same kind of variable Y? If variable Y has 10 integers: 8, 8, 5, 5, 5, 3, 1, 1, 1, 1 variable X would the integers 2, 2, 3, 3, 3, 1, 4, 4, 4, 4? Thank you a lot for any ideas. George * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Stop looping when reaching a certain observation***From:*George Chioran <george_chioran@yahoo.com>

**st: RE: Stop looping when reaching a certain observation***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**st: Count the number of observation of the same kind***From:*George Chioran <george_chioran@yahoo.com>

**st: RE: Count the number of observation of the same kind***From:*"Abhimanyu Arora" <abhimanyu.arora@student.kuleuven.be>

- Prev by Date:
**st: RE: Count the number of observation of the same kind** - Next by Date:
**st: RE: Count the number of observation of the same kind** - Previous by thread:
**st: RE: Count the number of observation of the same kind** - Next by thread:
**st: Code running Progress/estimated time** - Index(es):