Announcement

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

  • Wide to Long?

    Hi All,

    I was hoping to adjust the formatting of my data so that each variable will be covered by year in ascending order. So for 2012, there would be two observations, one for female and one for Asian. Similar to this snip. There are more variables than just Asian and female.

    Currently, it looks like: Click image for larger version

Name:	image_25182.png
Views:	1
Size:	5.9 KB
ID:	1641867

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year double(asian female)
    2012 .108 .147
    2013  .11 .152
    2014 .112 .155
    2015 .111 .154
    2016 .107 .149
    2017 .103 .142
    2018 .102 .134
    2019  .01 .124
    end
    Any help would be appreciated.

    Thanks,
    Last edited by Tyler Spencer; 21 Dec 2021, 14:41.

  • #2
    Bump

    Comment


    • #3
      On "Bump" please see #1 at https://www.statalist.org/forums/help#adviceextras

      Otherwise, you can do this, but on the face of it I wonder why you want it.

      Code:
      ds year, not 
      rename (`r(varlist)') (whatever=)
      reshape long whatever, i(year) j(which) string

      Comment

      Working...
      X