| jitter | Add noise to numeric variables to prevent overplotting | jitter |
The JITTER macro is defined with keyword parameters. The arguments may be listed within parentheses in any order, separated by commas. For example:
%jitter(var=X1-X5);
DATA=_LAST_]
OUT=_DATA_]
NEW=&VAR]
UNIT=1]
MULT=1]
SEED=0]
%include macros(jitter); *-- or include in an autocall library;
*-- Generate some discrete variables;
data test;
do i=1 to 10;
x1 = int(10*uniform(0));
x2 = int(10*uniform(0));
output;
end;
%jitter(data=test, var=x1 x2, new=y1 y2);
proc print;
var x1 y1 x2 y2;
proc gplot;
plot y2 * y1;
Printed output:
Obs x1 y1 x2 y2
1 8 8.19519 2 1.86667
2 0 -0.14863 1 0.78784
3 9 8.82106 9 8.82783
4 3 3.22831 8 8.20384
5 0 -0.10426 9 8.92621
6 0 0.18905 8 7.97462
7 1 0.79719 5 5.21546
8 2 2.06479 9 8.79396
9 8 8.19856 9 9.08425
10 7 6.81149 3 3.02668