DATA Step, Macro, Functions and more

Do statements

Reply
New Contributor
Posts: 3

Do statements

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!

 

Super Contributor
Posts: 490

Re: Do statements

[ Edited ]
Posted in reply to sasbeginner

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.

New Contributor
Posts: 3

Re: Do statements

Posted in reply to mohamed_zaki
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…



Super Contributor
Posts: 490

Re: Do statements

Posted in reply to sasbeginner

Then the above code is what you want.

Super User
Posts: 5,516

Re: Do statements

Posted in reply to sasbeginner

Perhaps your loops should begin like this:

 

do y=1 to 200; 

do i = 1 to y-1; 

Ask a Question
Discussion stats
  • 4 replies
  • 255 views
  • 1 like
  • 3 in conversation