Home > Software engineering >  Run a SAS macro through a loop and storing the results as a single table
Run a SAS macro through a loop and storing the results as a single table

Time:10-14

I need to run a SAS macro for number of iterations and save the output of the of the each iteration to a single table (each iteration as a row) I know to do this easily from R. But I don't have any idea to do the same using SAS.

Here is my sample data and code.

DATA HAVE;
input yr_2001 yr_2002 yr_2003 area;
cards;
1 1 1 3
0 1 0 4
0 0 1 3
1 0 1 6
0 0 1 4
;
run;

%macro cal_sum(w1,w2);
data wsum;
set Have;
wsum= yr_2001*&w1.   yr_2002*&w2.;
run;
proc means data = wsum mean;
var wsum;
run;
%mend;

%macro res;
%do i=1 %to 2;
%do j=1 %to 2;
%let p1=%eval(&i.*1/2);
%let p2=%eval(&j.*1/2);
           
  • Related