Announcement

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

  • error in reshape long, "no xij variables found"

    I am trying to reshape a database from wide to long--I've done this hundreds of times successfully over the years but something is wrong in this particular dataset and I haven't managed to track it down. I am using Stata 15.1. I pared my data down to essentials to try to track the error and I still get the message that r(111); "no xij variables are found". I have 4 variables; record_id, sex, bt1 and bt2 which are scores on a test taken at 2 time points. I want to go to having record_id, sex bt and visit in one line instead of record, sex, bt1 and bt2. Note, I've also tried this after dropping "sex" from the database to just record_id and bt1 bt2 and get the same error message, so I think it must be something wrong in the ID or the bt variables. Any advice gratefully appreciated!


    reshape long bt* sex, i(record_id) j(j)

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int record_id byte sex int bt1 float bt2
    130 2 219 226
    131 2 295 302
    132 2 283 290
    133 1 217 224
    134 2 222 229
    135 1 262 269
    137 1 258 265
    138 2 272 279
    139 2 259 266
    140 2 106 113
    141 2  90  97
    end
    label values sex sex_
    label def sex_ 1 "Masculino / Male", modify
    label def sex_ 2 "Femenino / Female", modify

  • #2
    reshape long requires stubs of variable names, so you want

    Code:
    reshape long bt, i(record_id) j(j)
    as you have bt1 and bt2, where the stub is "bt". See

    Code:
    help reshape
    Last edited by Andrew Musau; 29 Nov 2023, 10:18.

    Comment


    • #3
      Code:
      reshape long bt, i(record_id) j(j)
      reshape long wants to see stubnames, not variable names. Here I think btis the stub and sex just gets carried along.

      Comment


      • #4
        THANK YOU! I had forgotten that the "*" replaces the rest of the full name. Most grateful.

        Comment


        • #5
          Exemplary question that allowed a quick solution.

          Comment

          Working...
          X