I have a file which has approximately 22 variables and 56,000 student records. The students are enrolled in 228 schools. I want to collapse this file into a new sav file that contains one row per school (228 rows). I’d like that file to contain the 22 variables from the original file plus a new variable named student count that shows the number of students from each school that in the original file. I believe I want to use AGGREGATE with the school identification codes as my break variable. Does anyone know the syntax I would use to collapse the original file while at the same time adding the new student count variable to the output file? I am using SPSS 15.0 Thanks, Jim |
Administrator
|
"contain the 22 variables from the original file plus a new variable named student count" ????
Means of these variables or what??? AGGREGATE OUTFILE * / BREAK=School / M1 to M22=MEAN(v1 TO v22) / Student_Count=N. *Edited, forgot the BREAK clause ;-) *
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?" |
In reply to this post by james.moffitt
Hi Jim,
aggr out = * / break = school / n = n. This will give you a file with two variables: school and count. If you also want the other 22 vars, you need to decide how you want to aggregate them (sum, mean, min, max...). just add something like /sumvar = sum(var) at the end of the syntax. Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From: "[hidden email]" <[hidden email]> To: [hidden email] Sent: Thu, March 24, 2011 5:39:32 PM Subject: [SPSSX-L] Aggregate With New Count Variable I have a file which has approximately 22 variables and 56,000 student records. The students are enrolled in 228 schools. I want to collapse this file into a new sav file that contains one row per school (228 rows). I’d like that file to contain the 22 variables from the original file plus a new variable named student count that shows the number of students from each school that in the original file. I believe I want to use AGGREGATE with the school identification codes as my break variable. Does anyone know the syntax I would use to collapse the original file while at the same time adding the new student count variable to the output file? I am using SPSS 15.0 Thanks, Jim |
In reply to this post by David Marso
hey I didn't know 'TO" also works with AGGREGATE. That's handy. Thanks!
Albert-Jan ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From: David Marso <[hidden email]> To: [hidden email] Sent: Thu, March 24, 2011 8:14:07 PM Subject: Re: [SPSSX-L] Aggregate With New Count Variable "contain the 22 variables from the original file plus a new variable named student count" ???? Means of these variables or what??? AGGREGATE OUTFILE * / M1 to M22=MEAN(v1 TO v22) / Student_Count=N. james.moffitt wrote: > > I have a file which has approximately 22 variables and 56,000 student > records. > > The students are enrolled in 228 schools. > > I want to collapse this file into a new sav file that contains one row > per school (228 rows). > > I'd like that file to contain the 22 variables from the original file > plus a new variable named student count that shows the number of > students from each school that in the original file. > > I believe I want to use AGGREGATE with the school identification codes > as my break variable. > > Does anyone know the syntax I would use to collapse the original file > while at the same time adding the new student count variable to the > output file? > > I am using SPSS 15.0 > > Thanks, > > Jim > -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Aggregate-With-New-Count-Variable-tp4262861p4262906.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Administrator
|
That should save some keyboards and trees ;-)
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?" |
Free forum by Nabble | Edit this page |