-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealth.sas
103 lines (87 loc) · 1.77 KB
/
Health.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
filename sas_test '/home/u49317956/Udemy_SAS/sas_test.xlsx';
proc import datafile = sas_test
dbms = xlsx
out = hist1 replace;
getnames = yes;
run;
filename stat '/home/u49317956/Udemy_SAS/STAT.xlsx';
proc import datafile = stat
dbms = xlsx
out = stat1 replace;
getnames = yes;
run;
filename studht '/home/u49317956/Udemy_SAS/STUDHT.xlsx';
proc import datafile = studht
dbms = xlsx
out = studht1 replace;
getnames = yes;
run;
data both;
set stat1 hist1;
run;
proc sort data = both nodup;
by name;
run;
proc sort data = studht1 nodup;
by name;
run;
data merged;
merge both studht1;
by name;
run;
data result;
set merged;
weightkg = weight * 0.454;
heightm = height * 2.54/100;
bmi = weightkg/(heightm * heightm);
if bmi ne . then do;
if bmi lt 18 then status = 'Underweight';
else if bmi lt 20 and bmi ge 18 then status = 'Healthy';
else if bmi lt 22 and bmi ge 20 then status = 'Overweight';
else if bmi ge 22 then status ='Obese';
end;
run;
proc chart data = result;
pie status;
run;
proc freq data = result;
tables gender*status / out = new1;
run;
data new;
set new1;
value = cat(count, '(' , round(percent,0.1),'%',')');
drop count percent;
run;
proc sort data = new;
by status;
run;
proc transpose data = new out = new_t;
var value;
id gender;
by status;
run;
proc print data = new_t(drop = _name_);
title'Report of Frequency Table';
run;
%macro mystat(var1,var2);
proc freq data = result;
tables &var1*&var2 / out = new1;
run;
data new;
set new1;
value = cat(count, '(' , round(percent,0.1),'%',')');
drop count percent;
run;
proc sort data = new;
by &var2;
run;
proc transpose data = new out = new_t;
var value;
id &var1;
by &var2;
run;
proc print data = new_t(drop = _name_);
title'Report of Frequency Table';
run;
%mend;
%mystat(gender,status);