Announcement

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

  • Trying to add a new variable

    Hi, I am new to Stata, I would like some help on how to add a new variable.

    Basically, I got 6 different years in my data set e.g. 2009, 2010.2011, etc, and I would like to add the Gini coefficient for each year as a new variable, how can I do it?
    For example, I would like to see The new variable (Gini) shows that 2009 is 0.371 and 2010 is 0.392 for all samples. Since then I can run the regression model.

  • #2
    I don't understand why you want to do this, but:
    Code:
    gen Gini=.371 if year==2009
    replace Gini=.392 if year==2010
    etc.
    assuming here that the name of your year variable is "year" - if not, change accordingly; also assuming that year is numeric - please read and follow the advice in the FAQ so assumptions like these are not needed

    Comment


    • #3
      Thank you Mr Goldstein for solving my problem, this is very helpful. My work was stuck as this point but it is all sorted. Thank you very much

      Comment

      Working...
      X