*
; /****************************************************************/ /* S A S S A M P L E L I B R A R Y */ /* */ /* NAME: EQUATE MACRO */ /* TITLE: CREATES A GPLOT WITH DISTANCES EQUATED ON BOTH AXES.*/ /* PRODUCT: STAT */ /* SYSTEM: ALL */ /* KEYS: MACRO GRAPHICS */ /* PROCS: GPLOT MEANS */ /* DATA: */ /* */ /* SUPPORT: WFK */ /* REF: P-179, PROC CORRESP, EXAMPLE 3. */ /* MISC: YOU MUST LICENSE SAS/GRAPH SOFTWARE TO RUN PROC */ /* GPLOT. YOU MUST ALSO SPECIFY A GOPTIONS STATEMENT. */ /* */ /* TO USE MACRO EQUATE, FIRST %INCLUDE IT. */ /* */ /****************************************************************/ %macro equate(xmax=6.5, /* maximum x axis inches */ ymax=9, /* maximum y axis inches */ xinc=0.1, /* x axis tick increment */ yinc=0.1, /* y axis tick increment */ xpextra=0, /* include extra + end x axis ticks */ xmextra=0, /* include extra - end x axis ticks */ ypextra=0, /* include extra + end y axis ticks */ ymextra=0, /* include extra - end y axis ticks */ data=coor); /* input data set */ /*---------------------------------------------------------*/ /* */ /* Macro EQUATE creates a GPLOT of point labels with */ /* equated axes. */ /* */ /* This macro requires SAS/GRAPH software and a GOPTIONS */ /* statement. */ /* */ /* For vertical axis variable Y it creates an AXIS1 */ /* statement and for horizontal axis variable X it creates */ /* an AXIS2 statement such that an inch on the vertical */ /* axis represents the same data range as an inch on the */ /* horizontal axis. The 'extra' parameters are used to */ /* include extra ticks beyond the range of the data to */ /* accommodate long point labels within the boundaries of */ /* of the plot. */ /* */ /* Reset the defaults to be more suited to your devices. */ /* With minor modifications, other options could be */ /* specified. */ /* */ /* This macro performs no error checking. */ /* */ /*---------------------------------------------------------*/ *---Find the Minima and Maxima---; proc means noprint data=&data; var y x; output out=__temp__ min=ymin xmin max=ymax xmax; options nonotes; run; data _null_; set __temp__; *---Scale Minima and Maxima to Multiples of the Increments---; yinc = &yinc; xinc = &xinc; ymin = (floor(ymin / yinc) - (&ymextra)) * yinc; xmin = (floor(xmin / xinc) - (&xmextra)) * xinc; ymax = (ceil (ymax / yinc) + (&ypextra)) * yinc; xmax = (ceil (xmax / xinc) + (&xpextra)) * xinc; *---Compute the Axis Lengths---; ytox = (ymax - ymin) / (xmax - xmin); if ytox le ((&ymax) / (&xmax)) then do; xlen = &xmax; ylen = (&xmax) * ytox; end; else do; ylen = &ymax; xlen = (&ymax) / ytox; end; *---Write Results to Symbolic Variables---; call symput('len1',ylen); call symput('len2',xlen); call symput('min1',ymin); call symput('min2',xmin); call symput('max1',ymax); call symput('max2',xmax); call symput('inc1',yinc); call symput('inc2',xinc); run; options notes; *---Write the Generated Statements to the Log---; %put NOTE: The following statements were generated.; %put proc gplot data=&data%str(;); %put axis1 length=&len1 IN order=&min1 to &max1 by &inc1%str(;); %put axis2 length=&len2 IN order=&min2 to &max2 by &inc2%str(;); %put symbol1 v=none%str(;); %put plot y*x=1 / annotate=&data frame haxis=axis2 vaxis=axis1; %put href=0 vref=0%str(;); %put run%str(;); *---Create the GPLOT---; proc gplot data=&data; axis1 length=&len1 IN order=&min1 to &max1 by &inc1; axis2 length=&len2 IN order=&min2 to &max2 by &inc2; symbol1 v=none; plot y*x=1 / annotate=&data frame haxis=axis2 vaxis=axis1 href=0 vref=0; run; %mend equate; *;