*
; options nosource; %macro cart2pol (data,result,x,y,deg); options nosource nostimer nonotes nosymbolgen ; %if &data = and &result = and &x = and &y = or %upcase(&data) = HELP or &data = ? %then %do; %put This macro converts cartesian-coordinates to poloar-coordinates.; %put It should called by: CART2POL( data, result, x, y, deg ); %put where: ; %put data : name of input dataset, if missing _LAST_ is used; %put result : name of output dataset, default is _NEW_, with additional vars R and PHI; %put x : variablename of abscissa, default is X; %put y : variablename of ordinate, default is Y; %put deg : character value as deg or degrees and means PHI is in degrees; %put ; %goto fin; %end; %if &data = . %then %let data = _LAST_ ; %if &data = %then %goto quit_1; %if &result = or &result = . %then %let result = _NEW_ ; %if &x = or &x = . %then %let x = x; %if &y = or &y = . %then %let y = y; options notes; data &result; set &data; r = sqrt(&x**2 + &y**2); if r ^= 0 then phi = arcos(&x/r); else phi=0; run; options nonotes; %if ° = deg or ° = DEG or °=degree or °=DEGREE %then %do; data &result; set &result; if &y < 0 then phi = 360 - phi * 45/atan(1); else phi = phi * 45/atan(1); run; %end; %goto fin; %quit_1 : %put Please define input dataset; %fin : ; options source stimer notes; %mend cart2pol; options source; %cart2pol; /* Example data one; do phi=0 to atan(1)*8 by atan(1)/8; x=cos(phi); y=sin(phi); output; end; run; %cart2pol(one,two,x,y,deg); %cart2pol(one,zwei); */ *;