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 (November 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 25 Nov 2004 20:46:40 -0500
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: random partitions

Chang Y. Chung wrote: > On Thu, 25 Nov 2004 14:21:53 -0200, jlamack <jlamack@BOL.COM.BR> > wrote: > >> Dear all, I have a sas data set with 40 observations. >> I would like to get 8 random partitions of size 5 of this sas data >> set. Please, How can I do this?? > > A sort-less solution that requires 9's call ranperm. :-) >

A v9 solution using a hash and hiter. Not sure if ordered qualifies as sortless.

%let seed = 0;

data parts;

declare hash h (ordered:'a'); h.defineKey ('x'); h.defineData ('rowId'); h.defineDone ();

call missing (x, rowId, groupId);

do rowid = 1 to 40; x = ranuni (&seed); h.add (); end;

declare hiter hi ('h'); do _n_ = 0 by 1 while (hi.next()=0); groupId = floor (_n_/5); output; end;

stop;

drop x; run;

-- Richard A. DeVenezia http://www.devenezia.com/


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