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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 872 views
  • 0 likes
  • 3 in conversation