easy way to count no of schools. urgent

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

easy way to count no of schools. urgent

Anroh
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.
Reply | Threaded
Open this post in threaded view
|

Re: easy way to count no of schools. urgent

Bruce Weaver
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).


Anroh wrote
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.
--
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/).
Reply | Threaded
Open this post in threaded view
|

Re: easy way to count no of schools. urgent

David Marso
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.

Anroh wrote
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.
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?"
Reply | Threaded
Open this post in threaded view
|

Re: easy way to count no of schools. urgent

Bruce Weaver
Administrator
Quite right...I forgot to make the sorting explicit.

David Marso wrote
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.

Anroh wrote
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.
--
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/).