|
I don't see how an index ordered by the magnitude of the value of a within each
group b would help you randomly select one item per group. Why make it a
composite index problem?
Try:
proc sql;
create table sampl as
select distinct b,a,ranuni(111) as indx
from test
group by b
having calculated indx=max(calculated indx)
;
quit;
This selects at random a pair b,a for each unique value of b. Sig
-----Original Message-----
From: yorgiv@MY-DEJA.COM at Internet-E-Mail
Sent: Monday, July 10, 2000 8:48 PM
To: SAS-L@LISTSERV.UGA.EDU at Internet-E-Mail
Subject: index variable by group
Hello friends,
I would like to find a way to create an index variable in a single data
set by a group. An example will help of course:
A B
5 1
3 2
12 2
8 1
1 2
2 1
then i do this:
proc sort;
by B A;
run;
Now what I want is this:
B A index
1 2 1
1 5 2
1 8 3
2 1 1
2 3 2
2 12 3
I want to do this so that I can then use the ranuni function to
randomly select an A from each group of B. But I have trouble creating
the index variable as above. Thank you for any help,
Sincerely,
Yorgi V.
Sent via Deja.com http://www.deja.com/
Before you buy.
|