-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAScode.sas
More file actions
58 lines (49 loc) · 1.48 KB
/
Copy pathSAScode.sas
File metadata and controls
58 lines (49 loc) · 1.48 KB
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
*Final model;
* Please change the path to the folder that contains the datasets ;
* training.sas7bdat and validation.sas7bdat ;
libname JSMlib "C:\";
ods pdf file = "C:\SASOutput.pdf";
proc surveylogistic data= JSMlib.Training;
class IMP_ALCHL_IM(ref="2") IMP_SEX_IM(ref="1") IMP_VSURCOND(ref="1")
REGION(ref="1") IMP_LAND_USE(ref="1") overspeed(ref="0")/ param = ref;
weight WEIGHT;
cluster PSU;
strata PSUSTRAT;
model SEV(ref="PdoCrash") = IMP_TRAV_SP IMP_VE_TOTAL IMP_HOUR_IM IMP_VSPD_LIM
IMP_SEX_IM IMP_VSURCOND REGION IMP_SAFETY_RATING IMP_LAND_USE IMP_driver_age
overspeed IMP_ALCHL_IM/link=glogit covb df=infinity;*drop age since we have driver age;
store model2p;
output out=model2 predprobs=CROSSVALIDATE;
run;
ods pdf close;
proc plm restore=model2p;
score data=jsmlib.validation out=scored_model2 predicted/ ilink;
run;
*******************************check fitting result***************************;
data jsmlib.sort_scored_2;
set scored_model2;
run;
proc sort data=jsmlib.sort_scored_2; by _level_;
run;
proc surveymeans data=jsmlib.sort_scored_2 mean median std;
weight WEIGHT;
cluster PSU;
strata PSUSTRAT;
by _level_;
var predicted;
run;
proc surveyfreq data=jsmlib.training;
title "training data";
weight WEIGHT;
cluster PSU;
strata PSUSTRAT;
table sev;
run;
proc surveyfreq data=jsmlib.validation;
title "validation data";
weight WEIGHT;
cluster PSU;
strata PSUSTRAT;
table SEV;
run;
ods pdf close;