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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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