Announcement

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

  • Strange behavior of collapse command

    I have a problem with the collapse command in a dataset with 497 observations. When I collapse a numeric variable by a string variable, the number of observations is different on different computers. The type of string variable is str14. The command we use is as follows;

    clear all

    use testdata.dta
    collapse (mean) unity, by (InputID)

    After the above collapse command, the number of observations on windows computer is 227 while the number of observations on MAC is 235.

    We have been working for hours for this problem, We appreciate any suggestions.
    We have attached the data. Thank you very much in advance.

    Best
    Attached Files

  • #2
    You need to be clear that you are using the same .dta file. What you presented has 227 distinct values of InputID which are all str14 (and all have 0000 as a redundant middle part).

    Comment


    • #3
      Thank you for the answer. I will get back after checking the files again.
      Last edited by Upeksha Diss; 29 Nov 2022, 05:38.

      Comment


      • #4
        On my Mac using the dataset attached in post #1, we see 497 observations, none blank, with 227 distinct values.
        Code:
        . codebook InputID
        
        ------------------------------------------------------------------------------------------------
        InputID                                                                                  InputID
        ------------------------------------------------------------------------------------------------
        
                          Type: String (str14)
        
                 Unique values: 227                       Missing "": 0/497
        
                      Examples: "NG199000000407"
                                "NG199000001002"
                                "NG199000001406"
                                "NG199000001904"
        Added in edit: And the collapse command produces 227 observations.
        Code:
        . collapse (mean) unity, by (InputID)
        
        . codebook InputID
        
        ------------------------------------------------------------------------------------------------
        InputID                                                                                  InputID
        ------------------------------------------------------------------------------------------------
        
                          Type: String (str14)
        
                 Unique values: 227                       Missing "": 0/227
        
                      Examples: "NG199000000510"
                                "NG199000001014"
                                "NG199000001509"
                                "NG199000001903"
        
        .
        Last edited by William Lisowski; 29 Nov 2022, 07:17.

        Comment


        • #5
          My machine in #2 is under Windows. I strongly suspect that platform is immaterial here. The story lies elsewhere.

          Comment

          Working...
          X