Statalist


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

RE: Re: st: making sure on the graph


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   stata list <statalist@hsphsun2.harvard.edu>
Subject   RE: Re: st: making sure on the graph
Date   Fri, 4 Sep 2009 13:44:09 +0000 (GMT)

--- Maarten buis wrote:
> > An intermediate solution that will get the small graph 
> > while keeping the data intact is:
> >
> > . bys yearofbirth (wage): gen byte first = _n == 1
> > . egen meanwage = mean(wage), by(yearofbirth)
> > . scatter meanwage yearofbirth if first

--- Nick Cox wrote:
> Maarten's solution is good, but there is no need for the
> sorting within -yearofbirth-

This is correct. My solution came directly from my default 
library of tricks. In a general case this will make sure 
that first will tag an observation that has a valid 
(non-missing) value on whatever I am sorting on, in this 
case wage, unless all values of wage are missing within a 
category of yearofbirth. This is not relevant in this 
case as meanwage will always contain valid values. 

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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   |   What's new   |   Site index