-
Notifications
You must be signed in to change notification settings - Fork 0
/
MINOUTSENSUM.sas
157 lines (134 loc) · 3.75 KB
/
MINOUTSENSUM.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**********************************************************************************************************************/
/* Macro MINOUTSENSUM */
/* Last updated: 10/21/2018 */
/* Last run: 10/21/2018 */
/* This SAS macro carries out sensitivity analysis and calculates number of patients who fell during their nuring */
/* home stay by specifying different cutoffs,i.e., the number of days elapsed since nh discharge to hospital */
/* admission for fall */
/**********************************************************************************************************************/
dm 'log;clear;output;clear;';
%macro MINOUTSENSUM;
proc sql noprint;
create table fall_in_out_sensitivity
(
dschrg_admsn_days num 3,
N_fall_in num 8,
N_bene_in num 8,
);
quit;
%macro MINOUTSEN(daysin);
data claims_fallin(keep=BENE_ID);
set nhout.mdsclaims;
by bene_id;
length
r $1.
prev_a0310f $2.
prev_m_trgt_dt 4.
prev_A2000 4.
prev_A2100 $2.
fall_in 3.;
format
prev_m_trgt_dt
prev_a2000 date10.;
prev_a0310f =lag(A0310F_ENTRY_DSCHRG_CD);
prev_m_trgt_dt =lag(M_TRGT_DT);
prev_a2000 =lag(A2000_DSCHRG_DT);
prev_a2100 =lag(A2100_DSCHRG_STUS_CD);
if first.bene_id then do;
prev_a0310f =" ";
prev_m_trgt_dt =.;
prev_a2000 =.;
prev_a2100 =" ";
end;
if m_prvdrnum ne " " then r="M";
else if h_prvdrnum ne " " then r="H";
if r="H" then do;
if not first.bene_id then do;
if prev_a0310f in("10" "11") then do;
if prev_a2100 in("03" "09") then do;
d = h_admsndt - prev_a2000;
if abs(d) <=&daysin. then output claims_fallin;
end;
end;
end;
end;
run;
proc sql noprint;
select count(distinct bene_id), count(*) into: patient_fallin, : claims_fallin from claims_fallin;
quit;
proc sql;
insert into fall_in_out_sensitivity
set dschrg_admsn_days=&daysin.,
n_fall_in=&claims_fallin.,
n_bene_in=&patient_fallin.;
quit;
run;
%mend MINOUTSEN;
%MINOUTSEN(0)
%MINOUTSEN(1)
%MINOUTSEN(2)
%MINOUTSEN(3)
%MINOUTSEN(4)
%MINOUTSEN(5)
%MINOUTSEN(6)
%MINOUTSEN(7)
%MINOUTSEN(8)
%MINOUTSEN(9)
%MINOUTSEN(10)
%MINOUTSEN(11)
%MINOUTSEN(12)
%MINOUTSEN(13)
%MINOUTSEN(14)
%MINOUTSEN(15)
%MINOUTSEN(16)
%MINOUTSEN(17)
%MINOUTSEN(18)
%MINOUTSEN(19)
%MINOUTSEN(20)
%MINOUTSEN(21)
%MINOUTSEN(22)
%MINOUTSEN(23)
%MINOUTSEN(24)
%MINOUTSEN(25)
%MINOUTSEN(26)
%MINOUTSEN(27)
%MINOUTSEN(28)
%MINOUTSEN(29)
%MINOUTSEN(30)
%MINOUTSEN(31)
%MINOUTSEN(32)
%MINOUTSEN(33)
%MINOUTSEN(34)
%MINOUTSEN(35)
%MINOUTSEN(36)
%MINOUTSEN(37)
%MINOUTSEN(38)
%MINOUTSEN(39)
%MINOUTSEN(40)
%MINOUTSEN(41)
%MINOUTSEN(42)
%MINOUTSEN(43)
%MINOUTSEN(44)
%MINOUTSEN(45)
%MINOUTSEN(46)
%MINOUTSEN(47)
%MINOUTSEN(48)
%MINOUTSEN(49)
%MINOUTSEN(50)
%MINOUTSEN(51)
%MINOUTSEN(52)
%MINOUTSEN(53)
%MINOUTSEN(54)
%MINOUTSEN(55)
%MINOUTSEN(56)
%MINOUTSEN(57)
%MINOUTSEN(58)
%MINOUTSEN(59)
%MINOUTSEN(60)
data nhout.fall_in_out_sensitivity;
set fall_in_out_sensitivity;
run;
ods csvall file="S:\Pan\NH\results\paper\final\appendix\fall_in_out_sensitivity.csv";
proc print data=nhout.fall_in_out_sensitivity; run;
ods csvall close;
%mend MINOUTSENSUM;