Announcement

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

  • interactive variables

    Everywhere it says to use # to generate an interactive variable but when I put gen age#sqft I got 'variable age already defined' i.e. it refused to create this variable. Is there another way of going about it?

  • #2
    first, when generating a variable you need the multiplication symbol (*)

    second, if you actually typed "gen age#sqft", then you just confused Stata as the first thing after the "gen" should be the name of a new variable - in this case "age" but, as Stata tells you, age already exists

    third, why do you want to generate such a new variable? if you want to use it in some estimation command (e.g., -regress-), then you can do it on the fly; see
    Code:
    h fvvarlist

    Comment


    • #3
      Thank you. When I skipped gen and went straight to 'reg price age#sqft'
      I got 'factor variables may not contain noninteger values'. I thought factor variables were things like sex, region etc. so why is it talking about them here? Also googling h fvvarlist seems only to lead to further stuff about factor variables.

      Comment


      • #4
        The default is to assume that both variables forming the interaction are categorical. "sqft" if meaning Feet2 is continuous, so you need

        Code:
        age#c.sqft
        or better

        Code:
        i.age#c.sqft

        Comment


        • #5
          thank you, that works!

          Comment

          Working...
          X