How can I produce a count of the number of schools in a datasetWith a district id, school id and a student id School Id is a numeric variable. I have aggregated by the school id and
then produced a count of the number of cases, but this is time consuming. I know there must be a quicker way to do this, but it's not coming to me right now. |
Administrator
|
* Flag the first record for each school . match files file = * / by district schoolid / first = firstrec . * If you only want the number of schools in the output viewer, use this. descriptives firstrec / statistics = sum. * If you want NumSchools as a new variable, use AGGREGATE. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK= /NumSchools 'Number of schools'=SUM(v1).
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Administrator
|
In reply to this post by Anroh
If
(a) schoolID is unique across all the districts and (b) file is sorted by schoolID (OR all of a given schoolID are contiguous in the file then... IF $CASENUM=1 OR SchoolID NE LAG(SchoolID) TOP=1. FREQ TOP. NOTE: Bruce's MATCH approach requires the file be sorted by DistrictID SchoolID.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Administrator
|
Quite right...I forgot to make the sorting explicit.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
Free forum by Nabble | Edit this page |