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 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments:   To: sas-l@uga.edu
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


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