Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Schöler, Lisa <lschoeler@wiwi.uni-frankfurt.de> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: histogram |
Date | Thu, 14 Oct 2010 13:53:16 +0000 |
Dear Statalist, I have different observations within one id: Example +----------------------------------+ | id mean(brand) brand year | |--------------------------------| | 1 5 7 1999 | | 1 5 5 2000 | | 1 5 3 2001 | | 1 5 5 2002 | | 1 . . 2003 | |--------------------------------| | id mean(brand) brand year | |--------------------------------| | 2 . . 1999 | | 2 6 7 2000 | | 2 6 8 2001 | | 2 6 5 2002 | | 2 6 4 2003 | |--------------------------------| | id mean(brand) brand year | |--------------------------------| | 2 . . 1999 | | 2 6 7 2000 | | 2 6 8 2001 | | 2 6 5 2002 | | 2 6 4 2003 | +------------------------------+ Now I need to get a histogram that uses only one observation for each id for the mean(brand). Therefore I wanted to include a dummy=1, so I can use the command . histogram if dummy==1 Can anybody help me how I can create a dummy=1 only for one observation per id? I was gonna use . by id: gen dup = cond(_N==1,0,_n) and then . histogram if dup==1 But the problem here is that I have missings within my id groups, so sometimes my dup per id starts with 2. If anybody has a better idea than creating a dummy, I am very happy to hear about it. Thank you Lisa Lisa Schöler Professur für BWL, insb. Electronic Commerce Goethe-Universität Frankfurt Grüneburgplatz 1 60629 Frankfurt a.M. Phone: ++49 69 798 34632 Fax: ++49 69 798 35001 Email: lschoeler@wiwi.uni-frankfurt.de URL: www.ecommerce.wiwi.uni-frankfurt.de _________________________________ Get serious about better marketing decisions - apply now! http://www.goethe-master.de * * 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/