-
Notifications
You must be signed in to change notification settings - Fork 0
/
kmeans1.sas
85 lines (66 loc) · 1.69 KB
/
kmeans1.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%LET var = nbpers_au_foyer catholique protestant autre_religion
sans_religion marie concubin autre_relation celibataire
sans_enfant avec_enfant niv_etude_haut niv_etud_moy niv_etud_bas
PCStop PCScadre PCSagri PCSinter PCSouvr_quali PCSouvr locataire
proprietaire auto1 auto2 auto0 revenu1 revenu2 revenu3 revenu4
revenu5 ;
/* FORMAT SAS UTILISES */
PROC FORMAT ;
VALUE age
1 = ' < 30 ans'
2 = '30-40 ans'
3 = '40-50 ans'
4 = '50-60 ans'
5 = '60-70 ans'
6 = ' > 70 ans' ;
VALUE autrevar
0 = ' 0 %'
1 = '1 - 10 %'
2 = '11 - 23%'
3 = '24 - 36%'
4 = '37 - 49%'
5 = '50 - 62%'
6 = '63 - 75%'
7 = '76 - 88%'
8 = '89 - 99%'
9 = ' 100%' ;
RUN ;
libname bdsas "C:\SASTP";
data test;
set bdsas.assurancetic;
/* CREATION DE VARIABLES D'AGE */
DATA test ;
SET test ;
agemoins30 = (age_moyen = 1) * 9 ;
age30a40 = (age_moyen = 2) * 9 ;
age40a50 = (age_moyen = 3) * 9 ;
age50a60 = (age_moyen = 4) * 9 ;
age60a70 = (age_moyen = 5) * 9 ;
ageplus70 = (age_moyen > 5) * 9 ;
RUN ;
ODS OUTPUT Eigenvalues = valprop ;
PROC PRINCOMP DATA = test n=2 OUT=individus OUTSTAT=stat ;
VAR &var;
RUN ;
/*PROC STANDARD DATA= individus OUT=reduit MEAN=0 STD=1;
VAR &var;
RUN;*/
PROC FASTCLUS DATA=individus MAXC=20 MAXITER=50 CONVERGE=0.02
MEAN=centres OUT=partitio CLUSTER=presegm DELETE=5 DRIFT;
VAR &var;
RUN;
PROC PRINT DATA=centres (obs=20); RUN;
PROC PRINT DATA=partitio (obs=10); RUN;
PROC FREQ DATA=partitio ORDER=freq;
TABLE presegm;
RUN;
PROC FREQ DATA=centres;
TABLE _freq_;
RUN;
GOPTIONS RESET=all;
/*GOPTIONS COLORS=(green);*/
/*goptions csymbol=red;*/
PROC GPLOT DATA=partitio;
PLOT prin2*prin1=presegm;
RUN;
QUIT;