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]

From |
"Kieran McCaul" <Kieran.McCaul@uwa.edu.au> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: How to Randomly Assign 4 Integers to a Dataset? |

Date |
Fri, 12 Nov 2010 07:41:50 +0800 |

... clear* set obs 100 gen id=_n expand 4 gen x = 1 sort id by id: replace x = 5 if _n== 2 by id: replace x = 15 if _n== 3 by id: replace x = 20 if _n== 4 set seed 97883738 gen randn = runiform() sort id randn by id: keep if _n== 1 tab x -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Carly Petracco Sent: Friday, 12 November 2010 7:17 AM To: statalist@hsphsun2.harvard.edu Subject: st: How to Randomly Assign 4 Integers to a Dataset? I have 4 values that I want to randomly assign to the observations in my dataset. I do not want this to occur over a range (I know about runiform), all I have 4 integers (i.e. 1, 5, 15, 20) that I want to randomly assign to my observations, how do I do that? I have not been able to find a solution for this problem on the web or in previous questions, so any help would be greatly appreciates! Best, Charlie * * 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/ * * 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 Randomly Assign 4 Integers to a Dataset?***From:*Carly Petracco <carly.k.p@gmail.com>

- Prev by Date:
**Re: st: How to Randomly Assign 4 Integers to a Dataset?** - Next by Date:
**Re: st: gllamm estimates** - Previous by thread:
**Re: st: How to Randomly Assign 4 Integers to a Dataset?** - Next by thread:
**Re: st: How to Randomly Assign 4 Integers to a Dataset?** - Index(es):