DATA Step, Macro, Functions and more

Matlab matrix-calculation to SAS

Reply
N/A
Posts: 1

Matlab matrix-calculation to SAS

Hi,

I have problems converting a piece of Matlab-code into SAS. It concerns an iteration for a number (Nx) of items, all of different age. Depending on the age of each item I have to use parts of two function lambda(t1) and Fl(t2).

I have calculated lambda and Fl earlier in the program. I can store them either as data-step variables or as macro variables using call symput('lambda'||strip(t1),lambda);. The dataset with e.g lambda contains one column t1 and one column with the lambda-value.

IT.delday is stored in a data-set containing item-information.

For those of you how are not familiar with Matlab. The function “min” takes the minimum value of tau-1 and 365 and t1 is a vector with values spanning from 1 to the minimum value just calculated, in steps of 1. “.*” denotes element-wise multiplication.

for j = 1:Nx(k), %There are Nx items for period k
tau = calculationday-IT.delday(j); %tau is age of item on calculation day
t1 = [1:1:min(tau-1,365)];
t2 = tau-t1;
denom(k) = denom(k) + sum(lambda(t1).*Fl(t2));
end;

I really appreciate your help.
Annette
Ask a Question
Discussion stats
  • 0 replies
  • 116 views
  • 0 likes
  • 1 in conversation