Announcement

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

  • #16
    A question on my own behalf: Why do you use the "stable" option when sorting, which is rather unusual for me? Or is that just personal style?
    I very rarely use the -stable- option. I did so here for a particular reason. In this code, there are observations that appear to be pure duplicates. But, I suspect, just as you say you do, that in the full data set they may be distinguishable by other variables. When the code I showed in #14 is executed, the observations within id groups get assigned a sequence number, which, in turn, determines which observations populate which variables in the wide layout. Now, since id and admission date do not uniquely identify observations, if nothing else is specified about the sorting, Stata will randomize the sort order within id admission_date groups. In the back of my mind, I was thinking that in the real data set, other variables are in play (perhaps even a day of the month variable) and it might be best to implicitly sort on them. So on the hope that the current order of the data in fact corresponds to the order that would be desired for which observations populate which new wide variables, I specified -stable-. Admittedly, I do not know that this current order of the data really is appropriate to the purpose. But it is plausible to hope that that might be the case.

    So that's why I did that. I would say that, generally, the use of -stable- should be rare. Rule of thumb: if you're doing it more than once a year you're probably managing your data badly. But I did it in the hope (without supporting evidence) that O.P.'s data is, in fact, sorted in an order that is, in some sense, correct, but she does not tell us about it because she does not herself understand its implications or doesn't even realize the fact of the matter.

    Comment


    • #17
      Wow, thanks for the detailed explanation. I thought something like that when I read the relevant help page. Apparently I then correctly understood the use of the stable option. There are always numerous different solutions to almost every problem here and I always find it very exciting to see how other people approach the same problem. Thanks again for the explanation. It's always nice to learn something new!

      Comment

      Working...
      X