考虑VA 7.4 Designer中的列表表。它只有两个字段(月,中位患者)。希望计算几个月的累积中位数。该累积中位数标记为"中位患者"。附上了具有更多描述性步骤的示例数据。
拜托,看看。注意:通过使用VA 7.4 Designer中的中位数函数(不是愿望),很容易计算每月中位数患者。需要累积中位数。
谢谢你,玩得开心。
Sample Data
-------------
Account ID Month #patients
---------- ------- ----------
1 Jan2017 5
2 Jan2017 3
3 Feb2017 7
4 Feb2017 6
5 Feb2017 2
6 Mar2017 4
7 Apr2017 1
8 Apr2017 10
9 Apr2017 9
10 Apr2017 3
Typical calculation in SAS VA 7.4
-----------------------------------
Monthly Median (Easy using median function)
-------------------------------------------
Month Median Patients
--------- ---------------
Jan2017 4 ( 5+3 ) /2
Feb2017 6 middle of ( 2,6,7 )
Mar2017 4
Apr2017 6 middle of ( 1,3,9,10 ) = (3+9)/2 = 6
Cumulative Monthly Median (Desired in SAS VA 7.4) Any idea how to calculate this assuming this is in a List Table with only two fields (Month and Median Patients)?
------------------------------------------------------------------------------------------------------------------------------------------------------------
Month Median Patients
-------- -----------------
Jan2017 4 ( 5+3 ) /2
Feb2017 5 middle of ( 2,3,5,6,7 ) = 5
Mar2017 5 middle of (2,3,4,5,6,7 ) = (4+5) /2 = 4.5(approx. 5 when rounded)
Apr2017 5 middle of(1,2,3,3,4,5,6,7,9,10) = (4+5) /2 = 4.5(approx. 5 when rounded)
答案 0 :(得分:2)
通过SAS Code执行此操作;我Left Join
将month <= month
上的隔离数据自行data have;
infile datalines dlm=',' dsd;
informat Month monyy7.;
format Month monyy7.;
input Account_ID Month patients;
datalines;
1,Jan2017,5
2,Jan2017,3
3,Feb2017, 7
4,Feb2017,6
5,Feb2017, 2
6,Mar2017 , 4
7,Apr2017,1
8,Apr2017,10
9,Apr2017, 9
10, Apr2017 ,3
;
run;
(计算每个月的累积中位数)。
数据:
proc sql;
create table want as
select t1.Month , median(t2.patients) as Cumm_Median , round(median(t2.patients)) as Cumm_Median_rounded
from have as t1 left join have as t2
on t2.Month le t1.month
group by t1.month
order by t1.Month
;
quit;
累积中位数:
Month=JAN2017 Cumm_Median=4 Cumm_Median_rounded=4
Month=FEB2017 Cumm_Median=5 Cumm_Median_rounded=5
Month=MAR2017 Cumm_Median=4.5 Cumm_Median_rounded=5
Month=APR2017 Cumm_Median=4.5 Cumm_Median_rounded=5
输出:
.zshrc
答案 1 :(得分:2)
在VA Designer中: