UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SPSS Code Fragment
Using Aggregate

Collapsing data using aggregate.  This sums up the weights of the children in each family, and then saves that file as d:\famtot.sav.

data list list 
  / famid  * kidname (A4) birth * age * wt  * sex (A1) .
BEGIN DATA.
         1       Beth          1          9         60          f  
         1        Bob          2          6         40          m  
         1       Barb          3          3         20          f  
         2       Andy          1          8         80          m  
         2         Al          2          6         50          m  
         2        Ann          3          2         20          f  
         3       Pete          1          6         60          m  
         3        Pam          2          4         40          f  
         3       Phil          3          2         20          m  
END DATA.

SORT CASES BY famid.

AGGREGATE OUTFILE="d:\famtot.sav"
  /BREAK=famid
  /sumwt = sum(wt).

GET FILE = "d:\famtot.sav".

LIST CASES.  

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California