BookmarkSubscribeRSS Feed
Adeline34000
Calcite | Level 5
Hello,

I am a french student and i am studying an article where there is a SAS/IML code.

In this code, DES is a matrix of parameters, DELTA and EST are vectors. Delta={0,0,0,0} and EST is the vector of parameter estimates.

We calculate lambda=exp(DES*(-EST)) so lambda is a vector.

Then, to calculate the exposure at different time intervals (4 intervals) until time t=0 :

lambda_delta_t1=lambda # DELTA


In my application, # don't work because lambda and delta are vectors. I don't know how to do and I don't understand.

Thank you
7 REPLIES 7
Hutch_sas
SAS Employee
The # operator is element-wise multiplication, so it should work with two vectors provided the dimensions match up correctly. Both operands should be the same type (m x 1 or 1 x m) vector and have the same number of elements. It would be helpful to look at the article to better understand the author's intentions.
Adeline34000
Calcite | Level 5
http://aje.oxfordjournals.org/content/171/7/837.full

You can see the code in appendix 3.

Thank you very much
Adeline34000
Calcite | Level 5
Hello,

Can you at least explain to me what # should do between 2 vectors.
For example:

A={1,2,3,4};
B={5,6};

Is A#B={ 1*5 2*5 3*5 4*5,
1*6 2*6 3*6 4*6}

or A#B={1*5 1*6,
2*5 2*6,
3*5 3*6,
4*5 4*6}
?
nicolas_
Calcite | Level 5
Hi,

The code you posted just results in an error as the dimensions of both vectors don't match.

You can find the answer to your question in the following blog post.

http://blogs.sas.com/iml/index.php?/archives/48-Shorthand-Notation-for-Row-and-Column-Operations.htm...

Nicolas
Adeline34000
Calcite | Level 5
Hi,

My dimensions are correct according to the article:
lambda is a vector with 4304 rows
delta is a vector with 4 rows

I need to understand what the result of this operation is, to compute it on R.

What I have done today, but I think it's not correct because my final result are negative and they don't have to be it's:

lambda # delta = matrix with 4304 rows and 4 columns where
column i is lambda*delta(i)

Do you think I am right ?

The blog don't talk about operation between two vectors, and it's my problem. Message was edited by: Adeline34000
Adeline34000
Calcite | Level 5
PLease, nobody can tell me what result # should give between two vectors??
nicolas_
Calcite | Level 5
It doesn't do anything as the dimensions don't match up. If you execute the code as you say you get errors.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 7 replies
  • 1857 views
  • 0 likes
  • 3 in conversation