Announcement

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

  • Loop over variable with placeholder

    Hello,

    while trying some thing out, I got an error message for the following loop:

    local recode2 herkun1 herkunelt1 herkunelt2
    Code:
    foreach var of varlist `recode2' {
        recode `var'      (3=4) (4=5) (5=6) (6=3)
        recode `var'_d*   (3=4) (4=5) (5=6) (6=3)
    }
    At the same time, the normal recode with placeholder seems to work fine:

    Code:
    recode herkunelt2_d* (3=4) (4=5) (5=6) (6=3)
    Why is that the case? Are the two approaches not the same?
    AND: Is it in general possible to use placeholders within a loop?

    Best
    Marius

  • #2
    My apologies, I had an error in my thought process. The reason why it didn't work out was somewhere else. Unfortunately I didn't find the button to close the Post.

    Comment


    • #3
      Thanks for reporting back. Statalist won't allow members to close or delete threads unilaterally. The positive point is that Statalist is a public forum whose threads will usually be of interest to others.

      More at https://www.statalist.org/forums/help#closure

      Other places have different rules. Somewhere else I was surprised when my answer was deleted because the original poster, although sheltering behind a cryptic identifier, evidently wanted to cover their tracks and it seems that at that place people starting threads have ownership. Well, there you go.

      There can be good reasons -- usually a little or even very sensitive -- for wanting content to be deleted. One is that by accident you posted data that should be confidential. In such cases, reach out to the list administrators who will be reasonable given reasonable requests. Use the CONTACT US button to contain the administrators at StataCorp. (I am not an administrator, nor indeed a StataCorp employee.) (The CONTACT US button isn't visible if I look at Statalist on my phone, so I guess that could be true for others too.)

      Comment

      Working...
      X