Announcement

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

  • Question about less than missing (<".")

    Hi all,

    I have a question about
    Code:
    <"."
    and
    Code:
    !="."
    So what is the difference between these two?

    Best,
    Jack LiangWang

  • #2
    Your context here is string values, but as with numeric values but for different reasons their results can be quite different. The operator < (less than) means "would sort before" but sorting before is a matter of dictionary order.

    Here is a trivial example:

    Code:
    . di ("a" < ".")
    0
    
    . di ("a" != ".")
    1
    It's true that the character (letter) a is not equal to the character . but false that it would sort earlier.



    Comment


    • #3
      In addition to ".", Stata has extended missing values for numeric variables and sort them: . .a .b .c .....

      Code:
       if x <.
      excludes all missing values
      Code:
       if x !=.
      will include missing values larger than .
      If there are no extended missing, then the two are equivalent.
      Code:
      sysuse auto, clear
      replace rep78 = .a in 5   //extended missing
      tab rep78, missing
         Repair |
      Record 1978 |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                1 |          2        2.70        2.70
                2 |          8       10.81       13.51
                3 |         30       40.54       54.05
                4 |         17       22.97       77.03
                5 |         11       14.86       91.89
                . |          5        6.76       98.65
               .a |          1        1.35      100.00
      ------------+-----------------------------------
            Total |         74      100.00
      
       tab rep78 if rep78<., missing
      
           Repair |
      Record 1978 |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                1 |          2        2.94        2.94
                2 |          8       11.76       14.71
                3 |         30       44.12       58.82
                4 |         17       25.00       83.82
                5 |         11       16.18      100.00
      ------------+-----------------------------------
            Total |         68      100.00
      
      . tab rep78 if rep78!=., missing
      
           Repair |
      Record 1978 |      Freq.     Percent        Cum.
      ------------+-----------------------------------
                1 |          2        2.90        2.90
                2 |          8       11.59       14.49
                3 |         30       43.48       57.97
                4 |         17       24.64       82.61
                5 |         11       15.94       98.55
               .a |          1        1.45      100.00
      ------------+-----------------------------------
            Total |         69      100.00
      Last edited by Steve Samuels; 14 Aug 2018, 11:25.
      Steve Samuels
      Statistical Consulting
      [email protected]

      Stata 14.2

      Comment


      • #4
        Great, I got it. Thank you all.

        Best,
        Jack LiangWang

        Comment

        Working...
        X