Announcement

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

  • mrtab: error message if by variable is constant

    When using the SSC program mrtab by Ben Jann using the by() option with the by variable being constant, mrtab will issue the error message
    Code:
    '/' invalid observation number
    r(198);
    The user may wonder how to avoid the error message -- it will be issued if the by variable is constant. It would be helpful if mrtab would issue the error message "by variable is constant", instead.

    Here a reproducible example:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(hackmot1 hackmot2 hackmot3 hackmot4 hackmot5 hackmot6 hackmot7 hackmot8 hackmot9 hackltp)
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 1 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 1 1 0 1 1 0 0 0 1
    1 1 1 0 1 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 0 1 1
    1 0 1 0 0 0 1 0 0 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 1 0 0 0 0 1
    0 0 0 0 0 1 0 0 0 1
    1 0 0 0 1 0 0 0 0 1
    1 0 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 1 1 0 0 0 1
    0 1 0 0 1 0 1 0 1 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 1 0 0 0 0 1
    0 0 0 0 0 0 1 0 0 1
    0 1 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 1
    1 0 1 0 0 0 1 0 0 1
    0 1 0 0 0 0 0 0 0 1
    0 1 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 1
    0 0 0 0 0 1 0 0 0 1
    end
    label values hackmot1 hackmot1
    label def hackmot1 0 "not selected", modify
    label def hackmot1 1 "yes", modify
    label values hackmot2 hackmot2
    label def hackmot2 0 "not selected", modify
    label def hackmot2 1 "yes", modify
    label values hackmot3 hackmot3
    label def hackmot3 0 "not selected", modify
    label def hackmot3 1 "yes", modify
    label values hackmot4 hackmot4
    label def hackmot4 0 "not selected", modify
    label values hackmot5 hackmot5
    label def hackmot5 0 "not selected", modify
    label def hackmot5 1 "yes", modify
    label values hackmot6 hackmot6
    label def hackmot6 0 "not selected", modify
    label def hackmot6 1 "yes", modify
    label values hackmot7 hackmot7
    label def hackmot7 0 "not selected", modify
    label def hackmot7 1 "yes", modify
    label values hackmot8 hackmot8
    label def hackmot8 0 "not selected", modify
    label values hackmot9 hackmot9
    label def hackmot9 0 "not selected", modify
    label def hackmot9 1 "yes", modify
    label values hackltp hackltp
    label def hackltp 1 "yes", modify
    
    mrtab hackmot1-hackmot9, by(hackltp)
    The result will be
    Code:
    . mrtab hackmot1-hackmot9, by(hackltp)
    '/' invalid observation number
    r(198);
    Last edited by Dirk Enzmann; 13 Jun 2025, 09:46.
Working...
X