BookmarkSubscribeRSS Feed
cmshaw91
Calcite | Level 5

Hello all,

 

My organization does not have IML, only base SAS. So I'm using a macro compute matrix multiplications. This macro works but I have another macro that does matrix multiplaction i number of times.  When I run the following macro it only gives me a one period ahead matrix when it should give 6. Any thoughts?

 

%macro loop (n=);
%do i = 2 %to &n.;
data _null_; i_minus_1= &i.-1; call symput( 'i_minus_1', i_minus_1); run;
%if &i.=2 %then %do;
    %mat_product (in_data1 = m1
    ,in_data2 = m1
    ,out_data = m&i. );
  %end;
  %else %do;
   %mat_product (in_data1 = m1 , in_data2 = m&i_minus_1., out_data= m&i.);
  %end;
%end;
%mend;

%loop (n=6);

 

 

1 REPLY 1
Ksharp
Super User
I would use DATA STEP to calculate ,not MACRO which would lost accuracy .

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 1083 views
  • 0 likes
  • 2 in conversation