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]

AW: AW: st: a specific data management question


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: AW: st: a specific data management question
Date   Wed, 11 Aug 2010 17:30:29 +0200

<> 

I really do not understand where this is coming from. Grace`s wish was
exceptionally clear, and she (let`s hope I am guessing the gender right
here) declared herself satisfied with my solution. Tony`s solution would
also count missings, btw, which may not be obvious from his command...



*************
clear*

inp firm tag
1 0
1 .
1 1
1 1
1 3
2 0
2 1
2 2
2 3
3 0
3 0
3 .
end

egen tag1 = total(tag==1), by(firm)
egen tagb1=total(tag>=0), by(firm)
l, sepby(firm) noo
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Lachenbruch,
Peter
Gesendet: Mittwoch, 11. August 2010 17:20
An: statalist@hsphsun2.harvard.edu
Betreff: RE: AW: st: a specific data management question

What does this do to the tab=3 observation?  Do you want that to be part of
the total?  In that case you would want 
egen tagb1=total(tag>=0), by(firm)

________________________________________
From: owner-statalist@hsphsun2.harvard.edu
[owner-statalist@hsphsun2.harvard.edu] On Behalf Of Grace Jessie
[gracejessie@hotmail.com]
Sent: Wednesday, August 11, 2010 3:42 AM
To: statalist@hsphsun2.harvard.edu
Subject: RE: AW: st: a specific data management question

egen tag1 = total(tag==1), by(firm)

It is exactly what I want!
Thank you for all replies.

Grace

----------------------------------------
> From: martin.weiss1@gmx.de
> To: statalist@hsphsun2.harvard.edu
> Subject: AW: st: a specific data management question
> Date: Wed, 11 Aug 2010 09:13:24 +0200
>
>
> <>
>
> I think this code comes closer to Grace`s wishes, as the maximum was not
> really requested, but a count:
>
> *************
> clear
> input firm tag
> 1 0
> 1 0
> 1 1
> 1 1
> 1 3
> 2 0
> 2 1
> 2 2
> 2 3
> 3 0
> 3 0
> end
>
> egen tag1 = total(tag==1), by(firm)
>
> l, sepby(firm) noo
> *************
>
>
> As always, http://www.stata-journal.com/sjpdf.html?articlenum=pr0004 is
the
> best source...
>
>
> HTH
> Martin
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Michael N.
> Mitchell
> Gesendet: Mittwoch, 11. August 2010 06:27
> An: statalist@hsphsun2.harvard.edu
> Betreff: Re: st: a specific data management question
>
> How about this...
>
> clear
> input firm tag
> 1 0
> 1 0
> 1 1
> 1 1
> 1 3
> 2 0
> 2 1
> 2 2
> 2 3
> 3 0
> 3 0
> end
> egen tag1 = max(tag==1), by(firm)
>
> However, note that this gives a value of 0 if all values of tag are . for
a
> given firm.
>
> Hope this helps,
>
> Michael N. Mitchell
> Data Management Using Stata - http://www.stata.com/bookstore/dmus.html
> A Visual Guide to Stata Graphics -
http://www.stata.com/bookstore/vgsg.html
> Stata tidbit of the week - http://www.MichaelNormanMitchell.com
>
>
>
> On 2010-08-10 8.50 PM, Grace Jessie wrote:
> > firm tag
> > 1 0
> > 1 0
> > 1 1
> > 1 1
> > 1 3
> > 2 0
> > 2 1
> > 2 2
> > 2 3
> > 3 0
> > 3 0
> *
> * 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/
*
*   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