Announcement

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

  • using fill command with bysort and if

    Hello,

    I am struggling to run those two command
    bysort house floor: if floor == "F4 - F40" egen newvar = fill (4/40)

    bysort house floor: if floor == "F3 - F40" egen newvar2 = fill (3/40)

    for each combination of house and floor, I want to create a variable that takes as value the sequence from 3 to 40 or 4 to 40 depending of the value of floor.
    However stata tell me that if can not be combined with by and fill

  • #2
    I guess that you're expecting the fill() function of egen (strictly not a command) to work more or less in the way that the fillin command does. But that's just a guess.

    You're almost certainly confusing the if command and the if qualifier, which is easy to do. See https://journals.sagepub.com/doi/abs...urnalCode=stja if you have access.

    I suggest that you back-up and give us a real or realistic data example of what you have and one of what you want. The key is that if you already have 37 observations to populate with 4/40 -- or 38 to populate with 3/40 -- then the syntax would be one thing. If you don't have those observations they need to be created first.

    Comment

    Working...
    X