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

RE: st: Re: collapse syntax error


From   "Alexander Nervedi" <alexnerdy@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: Re: collapse syntax error
Date   Thu, 22 Sep 2005 19:07:26 +0000

Ramani,

Friedrich's solution is a better approach. Also, in case you need to use collapse again

collapse (sum) num, by(uhhid)

would do it. once collapsed you can rename the variable num.

hope that helps.
-Alnerdy



From: Friedrich Huebler <huebler@rocketmail.com>
Reply-To: statalist@hsphsun2.harvard.edu
To: statalist@hsphsun2.harvard.edu
Subject: st: Re: collapse syntax error
Date: Thu, 22 Sep 2005 11:57:44 -0700 (PDT)

Ramani,

You don't have to -collapse- your data to calculate the household
size.

. egen hhsize = sum(num), by(uhhid)

Friedrich Huebler

--- Ramani Gunatilaka <Ramani.Gunatilaka@BusEco.monash.edu.au> wrote:
> I am trying to calculate household size using collapse. The dataset
> has two variables, a unique household ID <uhhid> and the serial
> numbers of the household members <hhmem>.
> This is the code I used and the error I get.
>
> . /*create variable household size*/
> . use rindvar02, clear
>
> . keep uhhid hhmem
>
> . sort uhhid hhmem
>
> . gen num=1
>
> . collapse (sum) hhsize=num, by(uhhid)
> invalid syntax
> r(198);


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
*   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/
_________________________________________________________________
Donít just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/

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