Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
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 njcoxstata@gmail.com On 20 January 2014 08:57, Torsten Häberle <haeberle.torsten@gmail.com> 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/