*-----------------------------------------------* * QPLOT: GRAPHS A QUANTILE PLOT * * (quantiles against fraction of data) * * * * PARAMETERS NEEDED BY MACRO: * * data = name of the input dataset * * (default is _last_) * * var = name of the variable you want to plot * * gout = name of graphics catalog to output to * * (default is work.gseg) * *-----------------------------------------------*; %macro qplot(data=_last_,var=,gout=gseg); * Compute n and output to a new dataset; proc univariate data=&data noprint; var &var; output out = stats n = n ; * Create a global macro variable of n; data stats; set stats; call symput('n',n); * Sort the data by the plot variable and keep only the * plot variable to save sorting time and disk space.; proc sort data=&data out=sorted(keep=&var); by &var; data qdata; set sorted; i = _n_; fraction = (i - .5) / &n; if i = 1 or i = &n then do; x = fraction; y = &var; end; axis1 label=(angle=90 height=.75 "Quantiles of &var"); axis2 label=('Fraction of the Data'); symbol1 interpol=none value=circle color=black height=.5; symbol2 interpol=join value=none color=red; proc gplot data=qdata gout=&gout; plot &var*fraction y*x / vaxis=axis1 vminor=0 haxis=axis2 hminor=0 noframe overlay; run; quit; %mend qplot;