Consider the following nested DO Loops data doloops do x 1 t

&Consider; the following nested DO Loops: data doloops; do x 1 to 10 by 3; do y 1 to 5 by 2 x2 = x; y2 = y; t=x2 + 3*y2; output; end; end; proc print; run; quit; Question: Could you write a macro that would have the expression for t (as a function of x2 and y2), the starting value, the stopping value and the increment value of each loop all sent across as parameters? codes: 0.001 0.01 reasonable to assume a signit

Solution

SOLUTION:

options ls=78 nocenter nodate ps=55 mprint mtrace nodate nonumber formdlim = \'#\';
%macro indata1;
data doloops(expression,xstart,ystart,xstop,ystop,xincrem,yincrem);
%*read in data using nested do loops;
%do x = xstart %to xstop by xincrem;
%do y = xstop %to ystop by yincrem;
x2=&x;
y2=&y;
t= &expression;
output;
%*close the do loops;
%end;
%end;
%*print the data as a check;
proc print;
%mend indata1;

%indata1(x2+3*y2,1,1,10,5,3,2);javascript://
run;

I see this solution and you have a great solution for the problem

 &Consider; the following nested DO Loops: data doloops; do x 1 to 10 by 3; do y 1 to 5 by 2 x2 = x; y2 = y; t=x2 + 3*y2; output; end; end; proc print; run;

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site