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

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-06-2013 01:27 PM

Hello-

I am attempting to divide the values in rows of matrix A by the values in rows of matrix B. the columns of both are the same variables, the rows are different though and the number of rows are different.

I have create a scaled down version below of what I am trying to do:

A{ 1 3, 4 5}

B{ 5 9, 6 2, 7 1}

C{ .2 .33, .166 1.5, .14 3,

.8 .55, .66 2.5, .57 5}

Simply using C=A/B doesn't work, But I am wondering what does? Or if I need to use something other than IML?

Accepted Solutions

Solution

05-06-2013
01:56 PM

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

Posted in reply to ahappel

05-06-2013 01:56 PM

Let B1 = 1/B. Then what you are describing is a "direct product" that involves A and B1.

SAS/IML has two direct products: the "full" direct product is P=A@B. Your example is the first and last column of that direct product.

The second direct product is computed by using the HDIR function. What you want is the transpose of HDIR(A`, B1`).

If this is something you intend to use often, you might want to use the following helper function:

start VDIR(A,B);

return( T(hdir(A`,1/B`)) );

finish;

C = VDIR(A,B);

All Replies

Solution

05-06-2013
01:56 PM

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

Posted in reply to ahappel

05-06-2013 01:56 PM

Let B1 = 1/B. Then what you are describing is a "direct product" that involves A and B1.

SAS/IML has two direct products: the "full" direct product is P=A@B. Your example is the first and last column of that direct product.

The second direct product is computed by using the HDIR function. What you want is the transpose of HDIR(A`, B1`).

If this is something you intend to use often, you might want to use the following helper function:

start VDIR(A,B);

return( T(hdir(A`,1/B`)) );

finish;

C = VDIR(A,B);