如何在SAS VA 7.4 Designer中创建累积中值字段?

时间:2018-05-14 15:39:17

标签: sas

考虑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)

2 个答案:

答案 0 :(得分:2)

通过SAS Code执行此操作;我Left Joinmonth <= 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中:

  1. 创建一个名为monthyear的日期参数,并为其指定与Month字段相同的格式,
  2. 在报告正文中创建drop-down&amp; List-Table个对象,
  3. Month字段分配给drop-down,然后转到角色标签,在参数框中选择monthyear;你刚刚创建的,
  4. 选择List-Table,指定Month,Patient(确保聚合为中位数)然后转到过滤器选项卡并使用该点创建高级过滤器并单击:Month <= monthyear
  5. 现在设置了交互,确保从下拉列表中选择日期时,您会看到要计算的正确数据,将计算每月中位数
  6. dropdwon

    1. 从表格中删除月份/日期字段,然后计算累积中位数