turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-28-2012 11:43 AM

I'm trying to pull the lower half of a matrix in proc iml. It seems like the VECH function would work perfectly, but I'm running SAS 9.2 and VECH appears to be limited to 9.3. Any suggestions for alternatives? It's all inside a loop and the matrix size changes (with each loop), but these are fairly large matrices (e.g., 3000 X 3000). Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to coug914

04-29-2012 05:33 AM

This can be recreated using a short function module, but it is complicated slightly by the fact that the LOC function operates in row major order while the VECH function operates in column major order, and so the need to transpose the matrix. The code below should do the trick, but I have no idea how efficient or inefficient this might be with your large matrices.

proc iml;

start vechalf(x);

a=nrow(x);

b=a#a-1;

return(t(x)[loc(mod(0:b,a)>=int((0:b)/a))]);

finish;

x=shape(10:25,4,4);

print x;

y=vechalf(x);

print y;

quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to coug914

04-29-2012 01:00 PM

Actually it appears the symsqr function did what i needed.

thanks,

Rick

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to coug914

04-30-2012 03:55 AM

Thanks for the info, I had read this article and come to the conclusion that VECH was something completely new, but it appears that SYMSQR does the same thing, only it reads the lower diagonal elements in row-major order, so the two do give different results. It would be nice if the 9.3 documentation for VECH could be changed to include a link to SYMSQR (and vice versa).

Ian.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to IanWakeling

04-30-2012 08:48 AM

Thanks for the suggestion. The 9.3 documentation can't be changed, but the next release of the documentation will include links between SYMSQR <--> VECH and between SQRSYM <--> SQRVECH.