
/*********************************************************/
/* Title: Use Jittering to Offset Identical X,Y Values */
/*********************************************************/
/* Turn on options for debugging macros. */
options mlogic mprint symbolgen;
/* Set graphics environment */
goptions reset=all;
/* Create input data set, A */
data a;
input xvar yvar;
cards;
1000 1
1000 1
1000 1
100 2
100 2
100 2
100 2
100 2
100 2
200 3
500 4
500 4
600 6
700 7
300 50
300 50
;
run;
/* Sort data */
proc sort data=a out=sorted;
by xvar;
run;
/* Create output data set, FREQDATA */
proc freq data=sorted;
tables xvar*yvar / out=freqdata;
run;
/* Create data set, JITTER, which manipulates horizontal values used for plotting. */
data jitter;
retain xsys ysys '2' hsys '1' size 3 pos_neg 1
function 'symbol' color 'blue' text 'dot';
set freqdata;
pos_neg=1;
if count=1 then do;
xsys='2'; ysys='2';
x=xvar;
y=yvar;
output;
end;
if count>1 then do;
xsys='2'; x=xvar; y=yvar; output;
do i=1 to count-1 by 1;
if pos_neg=1 then x=xvar+(xvar*3*i/100); else x=xvar-(xvar*3*i/100);
y=yvar;
output;
pos_neg=-1*pos_neg;
end;
end;
run;
proc print data=jitter;
run;
/* Create title */
title1 'Offset Identical X,Y Values';
/* Produce plot */
proc gplot data=jitter;
plot y*x / haxis=axis1;
/* Create axis definitions */
axis1 offset=(3,3)pct;
/* Create symbol definitions */
symbol1 i=none v=dot c=red h=.5;
run;
quit;
|