Announcement

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

  • Interaction term of a global variable list with a factor variable

    Hi,
    I am using Stata 14.0 and trying to obtain full interaction of my variable list with a factor variable. Is there an easy way Stata allows me to do this while using global variable lists?

    Here is what I tried:

    global lexppr lexpretprice lexpfraprice /// Expected output prices
    global lcurrpr lretprice lfraprice /// Current output prices
    probit mzmktpos i.lc##c.($lexppr $lcurrpr) i.lc##i.(malehead year)

    Stata ran the regression but ignored the interaction of factor variable "lc" with my global variables : i.lc##c.($lexppr $lcurrpr). It did not give me an error message either.

    Thanks for any help in advance,
    Aakanksha

  • #2
    If this is the code that you actually ran, Stata did not run the regression, nor did it execute your -global lucurrpr- command. The reason is that you used the /// at the end of your commands. The /// token tells the Stata parser to a) treat whatever follows on the same line as comment, and b) treat the next line as a continuation of the command. Consequently Stata interprets the three lines of code you show as a single command defining a global macro that starts with lexpretprice and ends with i.lc##I.(malehead year).

    To get these to be three separate commands, and still preserve your comments, change the ///'s to //. // tells the parser to treat the rest of the line as a comment, but it does not treat the next line as a continuation of the command.

    Comment


    • #3
      Thanks much for the help Clyde! It works perfectly now. It was indeed a silly mistake on my part.



      Comment

      Working...
      X