LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2010, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 30 Mar 2010 09:23:23 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Assigning random numbers
Comments: To: Winter <>
In-Reply-To:  <>
Content-Type: text/plain; charset=ISO-8859-1

1. sounds like a case for PROC SURVEYSELECT to me. 2. depends on the real world use case, I think. If this is a learning problem then I'd think about why you will ultimately be using this kind of thing; if it is an actual real world case then you probably should provide more information, as IANAS but I suspect that there are possible reasons to either go with one out of 6 possibilities (to ensure all 6 are used at least once) or not.

If you don't end up using PROC SURVEYSELECT for the second, your basic construction is:

x = ranuni(seed); if x < proportion then ...; else if x < 2*proportion then ... ; ... else ;

where seed = some number you set or 0 for system timer assigned [I prefer not to use 0 as it is not repeatable; choose something that is somewhat random but is known, such as the current day, and then save it]. If you know how to use SELECT/WHEN then that's actually better than if/else here but both work fine.

If you end up needing to do the first by hand, there is a good page on the sas community wiki on how to use k/n sampling; I don't recall the complete solution but it's something like "if ranuni(seed) < k/n where k=remaining sample needed n=remaining population available then select this record".


On Tue, Mar 30, 2010 at 8:37 AM, Winter <> wrote:

> Hi, there are two things I am trying to do with random numbers that I > am having trouble with. Can anyone help me get started? Everything > I've read online has been pretty complex... > > 1. I have 15 people who need to be assigned to either task 1, 2, or 3. > They will only do one task and I want equal group sizes. > > 2. I have 10 people who will be doing all three tasks, but the order > in which they do them needs to be randomly assigned (1,2,3 or 1,3,2 > etc.). Here the number of people doesn't matter since there are six > possible orders. Do I need to make this like the previous problem > where I would basically assign the 10 people to condition 1-6, or is > there a way to get SAS to do the ordering itself? > > Thanks so much for the help! >

Back to: Top of message | Previous page | Main SAS-L page