Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Alberto R Osella <arosella@irccsdebellis.it> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: How to standardize a variable with a define mean |

Date |
Wed, 01 Feb 2012 11:05:45 +0100 |

Thanks Maarten. It works!!!! Alberto R. Osella, MD, PhD 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 Il 01/02/2012 10:48, Maarten Buis ha scritto:

On Wed, Feb 1, 2012 at 10:44 AM, Alberto R Osella wrote:I want to standardize a variable (BMI) with a given mean value. I've obtained that value from a -summarize- command, that is r(mean). Now I want to pass the value of r(mean) to the egen command. Here the commands and the error returned by Stata. . sum BMI . scalar meanbmi=r(mean) . display meanbmi 25.8435 . egen stdbmi=std(BMI), mean(meanbmi) std(1) option mean() incorrectly specified r(198);try: egen stdbmi=std(BMI), mean(`=meanbmi') std(1) The trick is that meanbmi is the name of a scalar while the -mean()- option expects a number. By surrounding that scalar name with " `= " and " ' " you are forcing Stata to first evaluate the scalar name, resulting in a number, which is exactly what the -mean()- option wanted. Hope this helps, Maarten -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: How to standardize a variable with a define mean***From:*Alberto R Osella <arosella@irccsdebellis.it>

**Re: st: How to standardize a variable with a define mean***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**st: Panel data** - Next by Date:
**Re: st: Listing var1 if var* equals X** - Previous by thread:
**Re: st: How to standardize a variable with a define mean** - Next by thread:
**RE: st: How to standardize a variable with a define mean** - Index(es):