【问题标题】:Isolate Patients with 2 diagnoses but diagnosis data is on different lines隔离有 2 个诊断但诊断数据位于不同行的患者
【发布时间】:2018-05-30 20:57:56
【问题描述】:

我有一个患者数据集,每个诊断都在不同的行上。

这是一个例子:

patientID diabetes cancer age gender 
1         1          0     65    M     
1         0          1     65    M     
2         1          1     23    M     
2         0          0     23    M     
3         0          0     50    F     
3         0          0     50    F

我需要隔离诊断为糖尿病和癌症的患者;他们的唯一患者标识符是 PatientID。有时它们都在同一条线上,有时它们不在同一条线上。我不确定如何执行此操作,因为信息位于多行上。

我该怎么做呢?

这是我目前所拥有的:

PROC SQL;
create table want as
select patientID
       , max(diabetes) as diabetes
       , max(cancer) as cancer
       , min(DOB) as DOB
   from diab_dx

   group by patientID;
quit;

data final; set want;
if diabetes GE 1 AND cancer GE 1 THEN both = 1;
else both =0;

run;

proc freq data=final;
tables both;
run;

这对吗?

【问题讨论】:

  • 取指标变量的最大值 BY PATIENTID。
  • 问题中的代码似乎产生了您想要的结果,因此它已经是正确的。您是否在问是否有其他更主要的方法来获得相同的正确结果?

标签: sas bioinformatics


【解决方案1】:

如果您想了解数据步骤查找的工作原理。

data pat;
   input patientID diabetes cancer age gender:$1.; 
   cards;
1         1          0     65    M     
1         0          1     65    M     
2         1          1     23    M     
2         0          0     23    M     
3         0          0     50    F     
3         0          0     50    F
;;;;
   run;
data both;
   do until(last.patientid);
      set pat; by patientid;
      _diabetes = max(diabetes,_diabetes);
      _cancer   = max(cancer,_cancer);
      end;
   both = _diabetes and _cancer;
   run;
proc print;
   run;

【讨论】:

    【解决方案2】:

    在 sql 查询末尾添加有语句应该可以。

      PROC SQL;
      create table want as
      select patientID
       , max(diabetes) as diabetes
       , max(cancer) as cancer
       , min(age) as DOB
      from PAT
    
      group by patientID
      having calculated diabetes ge 1 and calculated cancer ge 1;
     quit;
    

    【讨论】:

      【解决方案3】:

      您可能会发现一些编码人员,尤其是那些具有统计背景的编码人员,更有可能使用 Proc MEANS 而不是 SQL 或 DATA 步骤来计算诊断标志最大值。

      proc means noprint data=have;
        by patientID;
        output out=want 
          max(diabetes) = diabetes 
          max(cancer) = cancer
          min(age) = age
        ;
      run;
      

      或者对于所有相同聚合函数的情况

      proc means noprint data=have;
        by patientID;
        var diabetes cancer;
        output out=want max=  ;
      run;
      

      proc means noprint data=have;
        by patientID;
        var diabetes cancer age; 
        output out=want max= / autoname;
      run;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-23
        • 2018-08-16
        • 2018-01-16
        • 1970-01-01
        • 2018-01-04
        • 1970-01-01
        • 1970-01-01
        • 2019-11-02
        相关资源
        最近更新 更多