BookmarkSubscribeRSS Feed
AnnetteMH
Calcite | Level 5
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 0 replies
  • 580 views
  • 0 likes
  • 1 in conversation