Announcement

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

  • Adding rows under a variable

    Stata command for adding rows lets say 10 rows under a variable which has fixed observations like 40 for each unique id

  • #2
    Code:
    bysort id: gen last10 = _n > _N - 10
    expand 2 if last10

    Comment


    • #3
      Dear Snilsberg
      Thanks for your response. However, I am still stuck. If possible, can we connect over a virtual call.
      Thanks

      Comment


      • #4
        It's quite likely that a well-chosen data extract will help troubleshoot whatever you're stuck with. Doing it on the forum will also have the benefit of helping others who get stuck with similar issues.

        Please read the Statalist FAQ to help understand how to post effective questions, and for the rules of engagement on this forum. Sections 12 and 15 are immediately relevant.
        Last edited by Hemanshu Kumar; 23 Nov 2022, 06:56.

        Comment


        • #5
          Code:
          set obs 50
          would be a way of adding empty observations. But as Oyvind Snilsberg imples in #2 there would be reason to replicate earlier values, in which case expand is your friend.

          Comment


          • #6
            Thanks everyone. I have been able to solve this situation.

            Comment

            Working...
            X