Since you posted SAS/IML code, I will answer your question by using SAS/IML code.
Your code has a few problems:
1. In SAS, the "not equals" operators is "^=". You were using the C and Java syntax "!=".
2. The return value should be a.
3. In SAS/IML, arguments to a function are passed by reference. If you change an argument in a module, it changes the value that you passed in. For the GCD algorithm this will corrupt the input data, so you should copy the arguments before you begin to modify them.
proc iml;
start EuclidAlg(_a, _b); /*start function*/
a = _a; b = _b;
do while(b ^= 0);
t = b;
b = mod(a,b);
a = t;
end;
return(a);
finish EuclidAlg;
a = 1071;
b = 462;
gcd = EuclidAlg(a, b);
print gcd " is the GCD of " a " and " b;
/* validate by using the built-in GCD function */
validate = gcd(a,b);
print validate;
... View more