= SPSS Rank = The '''`RANK`''' command sets a variable equal to the case rank. <> ---- == Usage == {{{ rank variables=foo bar(A) baz(D). rank variables=foo bar(A) baz(D) /rank into new1 new2 new3. }}} See [[SPSS/SortCases|SORT CASES]] for the syntax of ranked variables. The '''`/RANK`''' subcommand is the default action. Specifying that subcommand allows for specifying output variable names. If the subcommand is not specified, or if it is specified without any or with too few output variable names, unique variable names will be automatically chosen. === Ties === Strategies for handling ties are: ||'''Option'''||'''Effect''' || ||`MEAN` ||Mean of tied ranks || ||`LOW` ||Lowest of tied ranks || ||`HIGH` ||Highest of tied ranks || ||`CONDENSE` ||Consecutive ranks for all groups|| The default is '''`/TIES=MEAN`''' ||'''foo'''||'''rank_mean'''||'''rank_low'''||'''rank_high'''||'''rank_condense'''|| ||0 ||3 ||1 ||5 ||1 || ||0 ||3 ||1 ||5 ||1 || ||0 ||3 ||1 ||5 ||1 || ||0 ||3 ||1 ||5 ||1 || ||0 ||3 ||1 ||5 ||1 || ||1 ||6.5 ||6 ||7 ||2 || ||1 ||6.5 ||6 ||7 ||2 || ||2 ||8 ||8 ||8 ||3 || === Ntiles === Compute the percentile for each N-tile with the '''`/NTILES`''' subcommand. For example, `/NTILES(4)` causes each quartile to be computed. {{{ rank variables=foo bar baz /ntiles(4) into new1 new2 new3. }}} === Proportion === Compute the proportion estimate with the '''`/PROPORTION`''' subcommand. {{{ rank variables=foo bar baz /fraction=blom /proportion into new1 new2 new3. }}} The '''`/FRACTION`''' subcommand specifies the method for computing a proportion estimate. By default, SPSS will use Blom's transformation. Alternatives include: ||'''Method'''||'''Effect''' || ||`BLOM` ||Blom's transformation: `(r – 3/8) / (w + 1/4)` || ||`RANKIT` ||`(r – 1/2) / w` || ||`TUKEY` ||Tukey's transformation: `(r – 1/3) / (w + 1/3)`|| ||`VW` ||Van der Waerden's transformation: `r / (w +1)` || === Normal === Compute the inverse of the standard normal cumulative distribution of the proportion estimate with the '''`/NORMAL`''' subcommand. {{{ rank variables=foo bar baz /fraction=blom /normal into new1 new2 new3. }}} The '''`/FRACTION`''' subcommand specifies the method for computing a proportion estimate. See `/NORMAL` for the specification. === N === Compute the number of cases, or sum of weights, with the '''`/N`''' subcommand. {{{ rank variables=foo bar baz /n into new1 new2 new3. }}} === RFraction === Compute the fractional ranks with the '''`/RFRACTION`''' subcommand. The computed values are ranks divided by the number of cases, or the sum of weights. {{{ rank variables=foo bar baz /rfraction into new1 new2 new3. }}} Combined with `/TIES=HIGH`, this is equivalent to cumulative frequencies. === Percent === Compute the fractional ranks as a percentage with the '''`/PERCENT`''' subcommand. The computed values are as created by `/RFRACTION` multiplied by 100. {{{ rank variables=foo bar baz /percent into new1 new2 new3. }}} === Savage === Compute the Savage (exponential) scores with the '''`/SAVAGE`''' subcommand. {{{ rank variables=foo bar baz /savage into new1 new2 new3. }}} === By === To rank cases within groups, specify the '''`BY`''' option. {{{ rank variables foo bar by baz. }}} === Missing === By default, SPSS will exclude observations with a user missing value for any variable. Add the '''`/MISSING=EXCLUDE`''' subcommand to explicitly allow this behavior, or add '''`/MISSING=INCLUDE`''' subcommand to disable it. ---- == Data model == The `RANK` command executes immediately. If there are any pending transformations, they execute first. ---- == See also == [[https://www.gnu.org/software/pspp/manual/html_node/RANK.html|PSPP manual for RANK]] ---- CategoryRicottone