I have worked in sas for a little over a year now off and on so I would still consider myself fairly new to the language. I am trying to compute Euclids Method to find the gcd using a do while loop in sas. I have never enjoyed loops, but I did take a stab at the loop and I pasted my code below. I do know that Euclids Method goes as follows: 1. a = b, then a (or b) 2. a>b, then gcd(a-b, b) 3. a<b, then gcd(a, b-a) I am trying to test the code on two random values like 18 and 48 for example. I want to be able to change a and b to whatever numbers I would like. My starting code is below. Any help would be greatly appreciated. Thank you in advance. proc iml; start func(a, b); /*start function*/ do while(b != 0); t = b; b = mod(a,b); a = t; output; end; return(?); /*? unsure what to put here*/ finish(func); run; quit;
... View more