-
Notifications
You must be signed in to change notification settings - Fork 96
/
cell.sas
55 lines (51 loc) · 1.69 KB
/
cell.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*------------------------------------*
| Macro to cellulate an X-Y data set |
*------------------------------------*/
%macro CELL( data=_LAST, /* input data set */
out=_DATA_,
x = X, y = Y, /* input X, Y variables */
xc=xc, yc=yc, /* output X, Y variables */
nx=15, ny=15); /* number of bins in X & Y directions */
/*-------------------------------------------------*
| Quantize the X and Y values into discrete cells |
*-------------------------------------------------*/
proc means data=&data noprint;
var &x &y;
output out=_temp_ range=rx ry;
data _cell_;
if _n_=1 then set _temp_;
set &data;
drop rx ry;
deltax = rx / &nx;
deltay = ry / &nx;
&xc = deltax * (round( &x/deltax )+.5);
&yc = deltay * (round( &y/deltay )+.5);
/*----------------------------------------*
| Find number of points in each X-Y cell |
*----------------------------------------*/
proc freq data=_cell_;
tables &xc * &yc / noprint out=&out ;
%mend CELL;
/*:
:*/
/*----------------------------------------------------*
| Macro to generate SYMBOL statement for each COUNT |
*----------------------------------------------------*/
%macro SUNSYM( data=_LAST_,ht=1.5, color=black );
%local alpha ch repeat;
%let alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZ;
proc means data=&data noprint;
var count;
output out=_temp_ max=maxcount;
data _null_;
set _temp_;
maxcount = min( maxcount, 26 );
call symput('HIGH',put(maxcount,2.));
run;
%let repeat=;
%do i=1 %to &HIGH %by 1;
%let ch = &i;
%if &i = 26 %then %let repeat = r=100;
symbol&i h=&ht f=sun c=&color v=%substr(&alpha,&ch,1) &repeat ;
%end;
%mend SUNSYM;