Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • rowranks

    Hello,

    is there a way to exclude 0 or missing values from rowranks ?


    Thank you.

  • #2
    I haven't used -rowranks (-ssc describe rowranks-) previously, but the -help- documentation for it indicates that by default, variables with missing values are excluded, and receive missing ranks. As for the 0s, you could temporarily recode them to some distinct missing values code, use -rowranks-, and then put their values back to 0s. For example:
    Code:
    clear
    input x1 x2 x3
    4 9 0
    3 . 6
    8 7 19
    end
    list
    //
    // Assuming the unusual missing code .z happens not to be used.
    recode x1 x2 x3 (0 = .z)
    list
    rowranks x1 x2 x3, gen(r1 r2 r3)
    list
    // Assuming you want to preserve the original 0s.
    recode x1 x2 x3 (.z = 0)
    list

    Comment


    • #3
      @Mike Lacy advises what I would advise, as the command author.

      rowranks is to be cited please as from the Stata Journal. The SSC version is older.

      Comment


      • #4
        Hello Nick and Mike,

        Thank you so much for your help. I was trying to paste my dataex, but sadly my computer cannot seem to paste. Hopefully the image is readable. The problem I am still having is, variable r4 should be rank 1 ( score is .6) and variable r1 should be ranked 2 (score .1428). Is there a way for missing to be ignored completely and not be taken into account for ranking?

        Thank you.
        Click image for larger version

Name:	Screen Shot 2023-01-16 at 12.20.56 PM.png
Views:	1
Size:	30.0 KB
ID:	1697461



        Code:
         rowranks ogisoescore wangkscore eischascore paulaoscore, gen (r1-r4) descending

        Comment


        • #5
          What you ask for is what rowranks tries to do, ignore missings. What you may be overlooking with descending is the highmissing option.



          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input float(var1 var2 var3 var4)
          1 .  2 4
          . 5 10 .
          end
          
          
          . rowranks var*, gen(r1 r2 r3 r4) descending highmissing
          
          
          .
          
          . rowsort var*, gen(s1 s2 s3 s4) descending highmissing
          
          . l
          
               +-------------------------------------------------------------------+
               | var1   var2   var3   var4   r1   r2   r3   r4   s1   s2   s3   s4 |
               |-------------------------------------------------------------------|
            1. |    1      .      2      4    3    .    2    1    4    2    1    . |
            2. |    .      5     10      .    .    2    1    .   10    5    .    . |
               +-------------------------------------------------------------------+
          
          .

          Comment


          • #6
            Hello Nick,

            That fixed everything thank you so much!


            Comment

            Working...
            X