Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Luca Campanelli <l.campanelli@yahoo.it> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: creating random groups of observations |
Date | Thu, 6 Dec 2012 01:28:47 +0000 (GMT) |
thank you, John, for your answer. I think that it would not work because I don't want each word to be in more than one group at the same time. Luca John Luke Gallup <jlgallup@pdx.edu> wrote: Luca, You can generate a lot more than a 1000, and delete those that don't meet your criteria. John On Dec 5, 2012, at 5:00 PM, Luca Campanelli <l.campanelli@yahoo.it> wrote: > I apologize for my previous email with no subject. > Dear Stata users, > I have a string variable "word" with 4000 words, and I'd like to create 1000 groups of 4 randomly selected words (the group of words will be trials in an experimental task). I also have info about the number of characters of each word. > > The dataset: > ID WORD CHR > 1 acorn 5 > 2 address 7 > 3 adult 5 > > One way to do it could be: > generate rdm = runiform() > sort rdm > egen group = seq(), from(1) to(1000) block(1) > > My question is if I can constrain the groups to meet a certain criterion: I'd like that each group of words has a total number of characters between given limits, for example between 18 and 28 total number of characters. I mean that I don't want groups with 4 short words or groups with 4 long words. > Do you know if there is any way to do it? > > Thank you for any help anybody can provide. > Luca Campanelli > > PS I have Stata IC 12.1 on Windows 7. * * 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/