| Date: | Thu, 9 Mar 2000 16:44:23 -0500 |
| Reply-To: | "Thomas J. Sullivan" <toms@RAND.ORG> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Thomas J. Sullivan" <toms@RAND.ORG> |
| Organization: | RAND |
| Subject: | Re: Select A Group of Random Records |
| Content-Type: | text/plain; charset=us-ascii |
*assume you want to randomly select 10 or less (in the event that there
are less than 10 in any group) from each group;
data nelson;
set nelson;
rand_num=ranuni(-5);
run;
proc sort data=nelson;
by area type;
run;
proc rank data=nelson out=ranknels;
by area type;
rank myrank;
run;
data subset;
set ranknels;
if myrank le 10; *substitute the target number of obs from each
group;
run;
Nelson Harrison wrote:
> I have a dataset that contains service orders for all of Ontario.
> Ontario is broken up into zones and there is 5 different types of
> service orders.
>
> What I need to do is select randomly 10-20 records for each type of
> service order for each area. For example, 10-20
> 'vvvv','wwww','xxxx','yyyy','zzzz' records for every area (approx 30
> areas).
>
> Dataset looks like the following
>
> Service
> Order # Type Area
> 123456 xxxx 1
> 234567 yyyy 2
> 345678 vvvv 2
> 456789 zzzz 3
> 567890 wwww 4
>
> etc. approx 3-4,000 records
>
> Thanks
>
> Nelson
|