Announcement

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

  • Dummy variables areg

    Hello all together,
    I am new here so please let me know if I asked my question properly. Unfornately, I cannot post output due to confidentiality issues but I hope you can still help me. I am a beginner in Stata and I have a problem with dummy variables in an areg-regression:

    I have a list of 33 dummy variables guts1-guts33 which stand for some variables of my dataset. I created them by "gen gutsd". Now I want to set some of them to 0 in my regression. I have tried to put the dummy variables in a macro:

    Code:
    • global gutsch guts2-guts4
    • areg q2 $treatments date $controls if count==1 & $gutsch==0 , robust absorb(zip)
    Problem: He seems to only set the first (guts2) to zero but i want him to set guts2, guts3 and guts4 to 0. If i put them in seperately it does the job but is not really an elegant way of doing it:

    [CODE
    • areg q2 $treatments date $controls if count==1 & guts2=0 & guts3 = 0 & guts4 =0, robust absorb(zip)
    [/CODE]

    I have not found anything but probably just did not look for the right thing.

    Thanks in advance and best regards

    Renato


  • #2
    set trace on often helps in debugging such problems. My guess is that when Stata (an it normally) interprets $gutsch it ends up with a statement that says
    & guts2-guts4==0 which doesn't work. If you're just starting with Stata, you should not worry much about elegance. A pile of conditional statements is a lot faster and easier than finding a cuter way.

    You could perhaps do

    egen temp=rowtotal(guts1-guts4)

    And then just have the conditional temp==0 in your areg statement. This of course assumes guts take on the values 0 and 1.

    You would need == in each of the equals in your second set of code. [This is part of the reason we like actual code - if you tried to run what you posted, it would not run so I assume you've run something else.]




    Comment

    Working...
    X