Statalist


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

st: Generate a random variable with a range constraint


From   David Collins <[email protected]>
To   [email protected]
Subject   st: Generate a random variable with a range constraint
Date   Sat, 06 Dec 2008 11:35:56 -0600

I apologise for what may be a fairly rudimentary question. I want to generate a random variable (wt), n = 5000; as follows;

 set obs 5000
 set seed 1000
 g wt = 70 * rnormal(1, 0.15)

However, wt also needs to be constrained as follows, 45 < wt < 95. I am having difficulty incorporating the constraint into the generate function, and would appreciate any help.

--David

--
David M Collins, Ph.D.
Dean & Professor, Faculty of Pharmacy
University of Manitoba, Apotex Centre
750 McDermot Avenue, Winnipeg  MB  R3E 0T5
CANADA.

Tel. 204-474-8794  Fax: 204-474-7617
Email: [email protected]

CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s)
is intended for the addressee(s) only and may contain confidential
information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and
any of its attachments (if any) is not authorized and may be unlawful.

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index