BookmarkSubscribeRSS Feed
sasbeginner
Calcite | Level 5

Hi, 

 

I have trouble running this. I would like values for x.  

 

data A; 

y=1 to 200; 

do i = 1 to 5 while (y-i>0); 

x=(y-i)*3;

output;  

end; 

 

 Thanks!

 

4 REPLIES 4
mohamed_zaki
Barite | Level 11

I am not sure what is the output you seeking is look like exactly ;

But maybe this is what you want

data A; 
do y=1 to 200; 
	do i = 1 to 5 while (y-i>0); 
		x=(y-i)*3;
		output;  
	end; 
end;
run;

So you will have two loops one for y and the other for i

and each loop should end by END; statment.

sasbeginner
Calcite | Level 5
I am trying to find all possible values for x when y is 1 to 200…

i.e. if i=5 and y=10 then x=15…



mohamed_zaki
Barite | Level 11

Then the above code is what you want.

Astounding
PROC Star

Perhaps your loops should begin like this:

 

do y=1 to 200; 

do i = 1 to y-1; 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 4 replies
  • 1924 views
  • 1 like
  • 3 in conversation