| Date: | Tue, 7 Jul 2009 07:01:34 -0700 |
| Reply-To: | smolkatz <smolkatz@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | smolkatz <smolkatz@GMAIL.COM> |
| Organization: | http://groups.google.com |
| Subject: | Re: IML |
|
| Content-Type: | text/plain; charset=ISO-8859-1 |
On Jul 7, 12:21 pm, Umrao <umraoa...@gmail.com> wrote:
> If I have an identity matrix say of order 4
> a=[1 0 0 0
> 0 1 0 0
> 0 0 1 0
> 0 0 0 1]
>
> Now i want to generate a new matrix of oder 6*4 using this as
> co1=a[1,]-a[2,];
> co2=a[1,]-a[3,];
> co3=a[1,]-a[4,];
> co4=a[2,]-a[3,];
> co5=a[2,]-a[4,];
> co6=a[3,]-a[4,];
> co=co1//co2//co3//co4//co5//co6;
> this output is like as under
> co=[1 -1 0 0
> 1 0 -1 0
> 1 0 0 -1
> 0 1 -1 0
> 0 1 0 -1
> 0 0 1 -1]
>
> I whant to generate this for any order of identity matrix.
> I am not able to run this in loop so please help me to solve this
> problem.
>
> regards,
> amit
Hi,
Here is solution, maybe not very beautiful, but working;
proc iml;
ord = {4};
a = i(ord);
dim = comb(ord,2);
co = j(dim,ord,0);
k = 1;
do i = 1 to (ord-1);
do j = (i+1) to ord;
co[k, ] = a[i, ] - a[j, ];
k = k+1;
end;
end;
quit;
Best,
Alexandra
|