Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "arosella" <arosella@irccsdebellis.it> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Take the value from variable X if year equals 2010 |
Date | Mon, 20 Jan 2014 10:21:54 +0100 |
gen yournewvariable= dollar*adjustmentfactor if year==2010 hope this help Alberto R. Osella Laboratorio di Epidemiologia e Biostatistica IRCCS Saverio de Bellis Via Turi, 27 70013 Castellana Grotte (BA) Italia tel: +39 0804994655 fax: +39 0804994650 e-mail: arosella@irccsdebellis.it Da: owner-statalist@hsphsun2.harvard.edu A: statalist@hsphsun2.harvard.edu Cc: Data: Mon, 20 Jan 2014 09:57:09 +0100 Oggetto: st: Take the value from variable X if year equals 2010 > 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/