Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: histogram


From   Andrea Bennett <mac.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: histogram
Date   Thu, 14 Oct 2010 16:01:23 +0200

Dear Lisa,

You might want to have a look at the tag-option of the egen command
http://www.stata.com/help.cgi?egen

best,

Andrea


On Oct 14, 2010, at 15:53 , Schöler, Lisa wrote:

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


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index