Announcement

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

  • generate a political party dummy variable HELP

    Hi, I am new to stata so would appreciate the help with what I realise is probably quite a basic question
    Essentially I am running a statistical project where we are looking at if political party affiliation effects view on britain. To run these regressions we have a data set that contains the variable "partyfw" which contains the list of parties. However I need to create dummy variables of each party so we can see the individual impact, how can i do this? when i enter the code: gen Conservative = (partyfw == "Conservative") it gives me an error message. Please help?

  • #2
    Just add i.partyfw to your regression model. The i. prefix makes the dummy (I prefer indicator) variables for you. The added advantage is that when using the i. prefix, Stata's post-estimation commands (like margins or etable) will know that these are indicator variables and can use that information.

    The fact that you ask a question here already tells us clear enough that you request our help. There is no need to add that to the question title, and certainly no need to SHOUT it.
    Last edited by Maarten Buis; 04 Apr 2024, 09:45.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      making some guesses about your data (please read the FAQ and follow its advice in the future), you could encode the data (you might want to set up labels first) and then use factor variable notation; see
      Code:
      h encode
      h fvvarlist

      Comment

      Working...
      X