Date: Sun, 29 Jan 2006 07:28:48 -0000 Ian Wakeling "SAS(r) Discussion" Ian Wakeling Re: Splitting Data Matrix by Column Levels Using PROC IML text/plain; charset="iso-8859-1"

Page,

You could use call execute for this. Note the design function used to identify the rows with the same levels will work even if the rows are not sorted by level.

Ian.

proc iml;

start split; A={1 10 20 40, 1 20 30 20, 1 30 40 20, 1 10 20 10, 1 20 30 30, 1 50 40 30, 2 10 10 10, 2 20 10 40, 2 50 40 30, 3 20 30 10, 3 50 40 30, 4 10 40 60, 4 20 20 30, 4 40 30 20, 4 10 10 20};

d=design(A[,1]); do i=1 to ncol(d); s=cats("A",char(i),"=A[loc(d[,",char(i),"]),];"); print s; call execute(s); end;

print A1,A2,A3,A4;

finish split; run split;

quit;

----- Original Message ----- From: "Page" <pagemoore@YAHOO.COM> To: <SAS-L@LISTSERV.UGA.EDU> Sent: Saturday, January 28, 2006 7:31 PM Subject: Re: Splitting Data Matrix by Column Levels Using PROC IML

> Actually after thinking about my problem a bit more, the actual size of > the resulting datasets are not equal. My DataA is obviously much > larger than this example, but for the purpose of the example each of > the levels in column 1 are actually different. The situation is more > like the following: > > DataA= {1 10 20 40, > 1 20 30 20, > 1 30 40 20, > 1 10 20 10, > 1 20 30 30, > 1 50 40 30, > 2 10 10 10, > 2 20 10 40, > 2 50 40 30, > 3 20 30 10, > 3 50 40 30 > 4 10 40 60, > 4 20 20 30, > 4 40 30 20, > 4 10 10 20}; > > The results should be as follows: > Data1= {{1 10 20 40, > 1 20 30 20, > 1 30 40 20, > 1 10 20 10, > 1 20 30 30, > 1 50 40 30} > > Data2= {2 10 10 10, > 2 20 10 40, > 2 50 40 30} > > Data3= {3 20 30 10, > 3 50 40 30} > > Data4= {4 10 40 60, > 4 20 20 30, > 4 40 30 20, > 4 10 10 20}

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