RegistryNo DateOfDiagnosis ExtentOfDisease Laterality HospitalFacility
1234 1/07/2006 DCIS L L-556
1234 1/12/2006 Invasive L L-556
2342 1/05/2004 DCIS R A-448
3565 1/06/2006 DCIS L L-556
3565 1/05/2005 DCIS R L-556
5678 1/09/2000 Invasive L L-556
6689 1/10/2001 DCIS L A-448
6689 1/01/1999 Invasive R A-448
如何将数据集转换为以下形式:
一个数据集,其中包含每例DCIS的记录,并带有二进制标记(是/否),指示该妇女是否已从DCIS变为侵袭性疾病,以及是否有时间发展为侵袭性疾病?
要分类为“进行中”的癌症,应首先分类为DCIS,然后再分类为同一乳房中的浸润性(即相同的侧斜度)。
答案 0 :(得分:2)
尝试一下(用您的实际表名更改“您的表”:
select
tbl_dcis.RegistryNo,
case when tbl_inv.RegistryNo is null then 0 else 1 end as progressed_to_invasive,
case when tbl_inv.RegistryNo is null then null else tbl_inv.DateOfDiagnosis - tbl_dcis.DateOfDiagnosis as difference_in_days
from yourtable as tbl_dcis
left join yourtable as tbl_inv on tbl_dcis.RegistryNo=tbl_inv.RegistryNo
where
tbl_dcis.ExtentOfDisease='DCIS'
and tbl_inv.ExtentOfDisease='Invasive'
and tbl_dcis.DateOfDiagnosis <= tbl_inv.DateOfDiagnosis