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 (July 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 10 Jul 2000 19:01:00 -0400
Reply-To:   HERMANS1 <HERMANS1@WESTAT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   HERMANS1 <HERMANS1@WESTAT.COM>
Subject:   Re: index variable by group
Comments:   To: yorgiv@MY-DEJA.COM
Content-Type:   text/plain; charset=US-ASCII

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.


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