Announcement

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

  • changing from wide to long, using mixed logistic model

    I would like to change the data from wide to long format and insert a variable which indicate (1) is the pre score and (2) post score

    Background:
    pre* - are scores measured pre-procedure, each variable pre* is scored 1-5. Each variable pre* represent a question of an ability to do something.
    post* are scores measured post procedure, each variable post* is scored 1-5. Each variable post* represent a question of an ability to do something after procedure


    Question:
    When I try reshape using help

    Code:
    reshape long pre* post*, i(ptid) j(qtype)
    Stata reports an error:

    You typed something like reshape wide a b, i(i) j(j).
    reshape looked for existing variables named a# and b# but could not find any.

    However I can't understand why it can not find pre* post* (seen datex sample below)

    I assume after reshaping, I'll have a variable which indicates 1 is the pre* and 2 is the post*


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(pre1 pre2 pre3 pre4 post1 post2 post3 post4 procedure) str2 surgeonid float ptid
    1 3 3 2 4 3 5 5 1 "11" 1
    2 4 5 3 3 5 4 4 0 "22" 2
    2 3 3 3 3 3 4 3 1 "11" 3
    . 4 3 4 4 1 1 3 1 "22" 4
    3 1 1 1 1 5 4 4 0 "22" 5
    end

  • #2
    You need stubs for reshape, so remove the asterisks. See

    Code:
    help reshape
    Code:
    reshape long pre post, i(ptid) j(qtype)
    Last edited by Andrew Musau; 23 Feb 2024, 08:16.

    Comment

    Working...
    X