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: Spss's aggregate vs stata's collapse.


From   Amadou DIALLO <stata.diallo@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Spss's aggregate vs stata's collapse.
Date   Wed, 13 Apr 2011 08:39:35 +0100

Hi,
I am translating spss commands to stata and have trouble with different outputs.
Results are different after "aggregate" for ceb (children ever born).
What am I doing wrong?


************************* STATA

. u wm

.
. su wmweight

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
    wmweight |     13232    .9711907    .8265843          0   9.415976

.
. *total children ever born.
. cap drop ceb

. g ceb = 0

. replace ceb = ceb + cm5a if cm4==1 & cm4 <.
(7139 real changes made)

. replace ceb = ceb + cm7a if cm6==1 & cm6 <.
(1906 real changes made)

. replace ceb = ceb + cm9a if cm8==1 & cm8 <.
(2643 real changes made, 1 to missing)

.
. su wage ceb [aw=wmweight]

    Variable |     Obs      Weight        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------------------
        wage |   12850  12850.7953    3.285289   1.880707          1          7
         ceb |   12849  12849.5159    1.673058   1.819984          0         12

.
. collapse (sum) ceb [aw=wmweight], by(wage)

. su wage ceb // [aw=wmweight]

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        wage |         7           4    2.160247          1          7
         ceb |         7    3043.916    1347.549     372.23   4025.187

************************* END






************************* SPSS
get file='WM.sav'.

DESCRIPTIVES
  /VAR=wmweight.


Descriptive Statistics
	N	Minimum	Maximum	Mean	Std. Deviation
Women's sample weight	13232	.000000	9.415976	.97119070	.826584294
Valid N (listwise)	13232				


weight by wmweight.

*total children ever born.
compute ceb = 0.
if (CM4 = 1) ceb = ceb + CM5A.
if (CM6 = 1) ceb = ceb + CM7A.
if (CM8 = 1) ceb = ceb + CM9A.

DESCRIPTIVES
  /VAR=wage.
Descriptive Statistics
	N	Minimum	Maximum	Mean	Std. Deviation
Age	12851	1	7	3.29	1.881
Valid N (listwise)	12851				


Warning # 3211
On at least one case, the value of the weight variable was zero, negative, or
missing.  Such cases are invisible to statistical procedures and graphs which
need positively weighted cases, but remain on the file and are processed by
non-statistical facilities such as LIST and SAVE.

DESCRIPTIVES
  /VAR=ceb.

Descriptive Statistics
	N	Minimum	Maximum	Mean	Std. Deviation
Enfants nés	12850	0	12	1.67	1.820
Valid N (listwise)	12850				


Warning # 3211
On at least one case, the value of the weight variable was zero, negative, or
missing.  Such cases are invisible to statistical procedures and graphs which
need positively weighted cases, but remain on the file and are processed by
non-statistical facilities such as LIST and SAVE.



aggregate outfile = 'tmpcmr.sav'
  /break wage
  /ceb = sum(ceb).

Warning # 3211
On at least one case, the value of the weight variable was zero, negative, or
missing.  Such cases are invisible to statistical procedures and graphs which
need positively weighted cases, but remain on the file and are processed by
non-statistical facilities such as LIST and SAVE.

get file='tmpcmr.sav'.

DESCRIPTIVES
  /VAR=wage.

Descriptive Statistics
	N	Minimum	Maximum	Mean	Std. Deviation
Age	7	1	7	4.00	2.160
Valid N (listwise)	7				


DESCRIPTIVES
  /VAR=ceb.

Descriptive Statistics
	N	Minimum	Maximum	Mean	Std. Deviation
ceb	7	365.76	4023.94	3071.1412	1363.65690
Valid N (listwise)	7				

************************* END


-- 

Amadou B. DIALLO, PhD.

Economist (Anti-Poverty Programs - DR Congo), AFTP3, The World Bank,
Washington DC.

Director, Center for Research and Training on Adult Health and Education.
Mayotte (FRANCE). www.aprosasoma.org

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