Rewrite the following program using %LET to assign the starting and ending values
of the DO loop to macro variables. Be sure these values also print in the PROC
PRINT output.
data sqrt_table;
do n = 1 to 5;
Sqrt_n = sqrt(n);
output;
end;
run;
title "Square Root Table from 1 to 5";
proc print data=sqrt_table noobs;
run;
the following is the answer:
%let start = 2;
%let stop = 7;
data sqrt_table;
do n = &start to &stop;
Sqrt_n = sqrt(n);
output;
end;
run;
title "Square Root Table from &start to &stop";
proc print data=sqrt_table noobs;
run;
why the 'start'=2 and 'end'=7 ?
Don't doubt yourself. If the first program you post is correct, then you can duplicate it by using the second DATA step and
%let start = 1;
%let stop = 5;
I don't see an "end"; I see a "stop".
Why 2 and 7? ask the author. May be to show that if you use
%let start = 1; %let stop = 5;
It duplicates the output from the first data step and that changing the values changes the output.
Don't doubt yourself. If the first program you post is correct, then you can duplicate it by using the second DATA step and
%let start = 1;
%let stop = 5;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.