Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Take the value from variable X if year equals 2010


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Take the value from variable X if year equals 2010
Date   Mon, 20 Jan 2014 09:20:08 +0000

su adj_factor if year == 2010

gen newdollar = dollar * r(mean)

For a more detailed and systematic review, see

http://www.stata-journal.com/article.html?article=dm0055


Nick
[email protected]


On 20 January 2014 08:57, Torsten Häberle <[email protected]> wrote:
> Hey,
>
> I have the following table
>
> Year      Adjustment factor       Dollar
> 2005              3                        500
> 2004              2                         200
> 2009              4                         300
> 2010              7                          400
> 2009              4                          200
> 2010              7                          100
> ....                   ...
>
> Now I want to generate a new variable. The new variable is
> Dollar * Adjustment factor of year 2010
>
> --> Basically, I want to multiply all my dollar values with the
> adjustment factor of 2010.
>
> This seems easy, but I don't get it.
> Something like:
> gen newdollar = dollar*(adjustment factor if year=="2010")
>
> Thanks
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index