Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: new: collapse2


From   Dan Blanchette <dan_blanchette@unc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: new: collapse2
Date   Wed, 4 Aug 2004 11:19:05 -0400 (EDT)

How about adding an option to save id variables during the -collapse-?
It would be great if you could do this:

. collapse2 (sum) grams kcal fat , by(personid) id(age gender sampwt stratum psu)

because age, gender etc do not vary within a person's set of observations.

I've been cheating -collapse- to get the same result by doing:

. collapse (sum) grams kcal fat , by(age gender sampwt stratum psu personid)

Thanks,


Dan Blanchette
Applications Analyst Programmer
Carolina Population Center UNC-CH
Dan_Blanchette@unc.edu




>From 	  "David Roodman" <DRoodman@cgdev.org>
>To 	  <statalist@hsphsun2.harvard.edu>
>Subject 	  st: new: collapse2
>Date 	  Tue, 3 Aug 2004 20:50:43 -0400
>
>I've just released an augented version of Stata's collapse command, called collapse2. The only change is that there are now four new "aggregation" operators:
>
>first --   first observation in group
>last  --   last
>firstnm -- first non-missing
>lastnm  -- last non-missing
>
>Data must be tsset to use the operators. I find these convenient for example for converting a panel data set with annual observations to one with decadal observations where I need such variables as initial
>GDP and initial population.
>
>To install, type "ssc install collapse2". Comments welcome.
>
>David Roodman
>Center for Global Development
>droodman@cgdev.org


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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