Announcement

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

  • "Weights not allowed" when copying previous values downwards

    Dear all,

    I want to copy some values from previous cells and furthermore to create the cascade effect.
    I read and tried the code that I f
    ound in the STATA faq:

    replace myvar = myvar[_n-1] if myvar >= .

    However, I receive the following message "weights not allowed". What should I do in the wrong way? Thanks in advance for your time!!!

    Kind regards,
    Ioannis Efraimidis

  • #2
    I just solved it.

    Firstly,you have to install the carryforward package. The last thing you have to do is to sort the dataset by the id and to write the following command:

    bysort newid: carryforward myvar, gen(myvar2)

    Comment


    • #3
      Your code looks good to me, not least because the FAQ you're alluding to

      https://www.stata.com/support/faqs/d...issing-values/

      has good parentage. (Please give precise references.)

      Code:
      replace myvar = myvar[_n-1] if myvar <= . 

      I guess you typed something different. Show us exactly what you typed, not what you tried to copy. For example, putting extra spaces before the [_n-1] could be a problem.

      Please note:

      http://www.statalist.org/forums/help#stata

      http://www.statalist.org/forums/help#spelling

      P.S. There is no need to install carryforward (SSC). It's fine, but the FAQ explains the principle in terms of one command line you can apply. In your case, you would need a by: prefix as well as the code above.

      Comment

      Working...
      X