BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

 

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

 

tianerhu
Pyrite | Level 9
sorry , it is 'stop' instead of 'end'.
tianerhu
Pyrite | Level 9
Thank you for your help.
Rick_SAS
SAS Super FREQ

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;

 

tianerhu
Pyrite | Level 9
Thank you for your help ..

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1025 views
  • 0 likes
  • 3 in conversation