*
;

                 options nosource;
%macro pol2cart (data,result,r,phi,deg);
options nosource nostimer nonotes nosymbolgen ;
  %if &data =  and &result =  and &r =  and &phi =  or
            %upcase(&data) = HELP or &data = ? %then %do;
     %put  This macro converts polar-coordinates to cartesian-coordinates.;
     %put  It should be called by:  POL2CART( data, result, r, phi, 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 X and Y;
     %put  r       :  variablename of radius in input dataset, default is R;
     %put  phi     :  variablename of angle in input dataset, default is PHI;
     %put  deg     :  character value as deg or degrees and means angle 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 &r   =  or &r   = . %then %let   r = r;
  %if &phi =  or &phi = . %then %let phi = phi;
  %if ° =  deg or ° = DEG or °=degrees or °=DEGREES
    %then %let phi = %str(&phi *atan(1)/45);

data &result;
  set &data;
  x = &r*cos(&phi);
  y = &r*sin(&phi);
run;

 %goto fin;
 %quit_1 : %put Please define input dataset;
 %fin : ;

options source stimer notes;
%mend pol2cart; options source;

/* Examples

data one;
  do phi=0 to atan(1)*8 by atan(1)/8;
     r=ranuni(0);
     output;
  end;
run;
data eins;
  set one;
  phi = phi*45/atan(1);
run;

%pol2cart(eins,zwei,r,phi,deg);

axis1 length=7 cm ;
symbol i=join r=123;
proc gplot;
  plot y*x/haxis=axis1 vaxis=axis1;
run; quit;

%pol2cart(one,two,r,phi);

proc gplot;
  plot y*x/haxis=axis1 vaxis=axis2;
run; quit;
*/
%pol2cart;

*
;