Announcement

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

  • Interaction variable (using dummy and date variables)

    Hello everyone,

    I am trying to create an interaction variable by multiplying a dummy variable (0,1) with a date variable. I am thinking that for all values of 0 multiplied by the date should be 0, while those multiplied by 1 should be the same as the date. I realize that once I format the interaction variable to a date variable, I get a date of 1960m1 for those multiplied by 0. I have included an example and would be grateful to know if there is a way to get 0 values for the interaction variables instead of the '1960m1' date.

    Thank you.

    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(after_policy date date_after)
    1 1993m6 1993m6
    0 1991m2 1960m1
    0 1992m8 1960m1
    1 1993m7 1993m7
    0 1991m7 1960m1
    end



  • #2
    What you see as 1960m1 is 0. The 1960m1 is just a way of presenting it so that it looks like a monthly date to your eyes. But internally, it is just 0.

    That said, there is no reason to create this variable. You are, I presume, going to do a regression in which you want to have an interaction between after_policy (dichotomous) and date You are best advised to do this using factor-variable notation:

    Code:
    regression_command outcome_variable i.after_policy##c.date perhaps_other_variables
    Read -help fvvarlist- for more information.

    Comment


    • #3
      Thank you so much.

      Comment

      Working...
      X