f



Re: how to quit / return from "if then"? #4 677943

On Thu, 16 Nov 2006 12:52:42 -0800, muster <muster@GMAIL.COM> wrote:

>Thanks to Michael, it was missing a ; after do. I corrected it and go a
>new problem.
>
>It executes do ... end, then still run the rest of the program, which
>is not what I wanted. How to make it quit running the program totaly?

Please provide a more complete example, or at least indicate the context in
which you are running this code.

The SAS DATA step does *not* have a PRINT statement.

Perhaps this is just sloppiness and the "real" (DATA step) code has a PUT
statement there. In that case, try replacing the RETURN with DELETE. That
will suppress the default output of the error cases.

>
>Thanks,
>
>muster
>
>
>muster wrote:
>> Hello all,
>>
>> I got an error in here saying "DO" not executed before quit.
>>
>> if ( a = 0 ) then
>> do
>>     print "error";
>>     return;
>> end;
>>
>> How to deal with it? Thanks,
>>
>> muster
0
nospam1405 (4666)
11/17/2006 4:23:37 AM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

1 Replies
298 Views

Similar Articles

[PageSpeed] 5

Hi all, thanks, here is a part of the code that is relavant.

I want it exit the current PROC (just do nothing after the return /
stop), it does not print "no error", but seemingly SAS keeps finishing
all other statements.

Thank you,

muster

***************************************************

quit;
/* main function */
proc iml;
SIGMA = {1 -.5 -.5, -.5 1 -.5, -.5 -.5 1};	/* covariance matrix */
det = abs(det(SIGMA)); 		/* determinant of cov matrix */
if (det = 0) then do;
	print "dependent cov matrix";
	return; /* same if stop here */
	end;

	print "no error";

PI = 4 # atan(1);			/* constant PI */
C = (2 # PI) ## (3 / 2) # det ## .5;
C = 1/C;					/* constant of pdf */

mean = {1 2 3};
xx = .M || 0;
yy = .M || 0;
zz = .M || 0;

run;

0
muster (11)
11/17/2006 7:41:44 PM
Reply: