Announcement

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

  • reshaping wide to long week1day1 variable

    Hi All
    I have a dataset with stepcounts over 12 weeks with variables named as week1day1 to week12day7 format and
    I want to change it to long format with week and day variables seperately. I have a subjectID as a unique variable.
    Suggestions will be appreciated.

  • #2
    Welcome to Statalist.

    You will need to use the reshape command twice, something like
    Code:
    reshape long week1 week2 week3 week4 week5 week6 week7 week8 week9 week10 week11 week12 , i(subjectID) j(sday) string
    generate day = real(substr(sday,4,1))
    reshape long week, i(subjectID day) j(week)
    With that said, I have less than perfect faith in this because you shared no data for us to test it on. And with data to test with, I might have found a more elegant solution.

    To improve your future posts, please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment


    • #3
      Thank you William ,It perfectly worked as I wanted. I am so happy to join Statalist

      Comment

      Working...
      X