I have a dataset that has several variables, School, Year, Measure1, Measure2, Measure3. The cases have yearly data for about 200 schools, over a series of years.
For each MeasureI, I would like to run Rank for each year, and add a couple of ranking variables. I tried Splitting Files over Years, and then running Rank. I hoped that that would give me yearly rankings, but it did not. Instead, I got rankings over all cases.
I tried Select Cases, which worked the first time. When I tried a different year, SPSS wanted to add a new variable, and would not fill in the previously generated ranking variables.
I looked to see if there was an extension command, along the lines of SPSS Plot Subgroups, that would do this, but I couldn't find one. Has anyone written a procedure that would automatically
breakout separate datasets, run rank on each, and then combine the datasets? Presumably, it would be a Python routine that manage the loops, and generate SPSS commands to load datasets, run Rank, and then combine the files.
Gary |
Doesn't BY handle this for you?
RANK x BY year. ? Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: Gary Rosin <[hidden email]> To: [hidden email], Date: 06/25/2014 08:12 PM Subject: [SPSSX-L] Ranks on Subgroups Sent by: "SPSSX(r) Discussion" <[hidden email]> I have a dataset that has several variables, School, Year, Measure1, Measure2, Measure3. The cases have yearly data for about 200 schools, over a series of years. For each MeasureI, I would like to run Rank for each year, and add a couple of ranking variables. I tried Splitting Files over Years, and then running Rank. I hoped that that would give me yearly rankings, but it did not. Instead, I got rankings over all cases. I tried Select Cases, which worked the first time. When I tried a different year, SPSS wanted to add a new variable, and would not fill in the previously generated ranking variables. I looked to see if there was an extension command, along the lines of SPSS Plot Subgroups, that would do this, but I couldn't find one. Has anyone written a procedure that would automatically breakout separate datasets, run rank on each, and then combine the datasets? Presumably, it would be a Python routine that manage the loops, and generate SPSS commands to load datasets, run Rank, and then combine the files. Gary ===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (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 ===================== 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
|
In reply to this post by Gary Rosin
Sometimes things are simply obvious if one does a bit of reading.
Lacking that one comes up with all sorts of Rube Goldberg type approaches! From the FM. RANK > VARIABLES "To organize ranks into subgroups, specify keyword BY followed by the variable whose values determine the subgroups. The active dataset does not have to be sorted by this variable." As can be seen by my example RANK DOES work with SPLIT FILE indicating your process of inquiry/validation must be somewhat sketchy? DATA LIST FREE/gp x. BEGIN DATA 1 1 1 5 1 4 1 3 2 10 2 11 2 9 2 5 END DATA. RANK x /RANK INTO rx. RANK x BY gp /RANK INTO rxBygp. SPLIT FILE BY gp. RANK x /RANK INTO rsplitx. SPLIT FILE OFF. LIST. gp x rx rxBygp rsplitx 1.00 1.00 1.000 1.000 1.000 1.00 5.00 4.500 4.000 4.000 1.00 4.00 3.000 3.000 3.000 1.00 3.00 2.000 2.000 2.000 2.00 10.00 7.000 3.000 3.000 2.00 11.00 8.000 4.000 4.000 2.00 9.00 6.000 2.000 2.000 2.00 5.00 4.500 1.000 1.000 Number of cases read: 8 Number of cases listed: 8
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 |