死因分析sas代码

该博客分享了如何利用SAS对人口死亡数据进行分析,涉及到的数据文件包括population.xlsx、table_ttle.csv、table_male.csv、table_female.csv以及icd10.xlsx,同时提供了code.xlsx作为分析代码模板。可以通过提供的百度云链接下载数据和模版进行学习。
摘要由CSDN通过智能技术生成
options mstored sasmstore = reporter;
options papersize = a4 orientation = landscape;
libname reporter 'E:\2017\死因监测\总结\';

%let dir = E:\2017\死因监测\总结\;
%let base = 11.csv; *大疫情死因系统导出死因数据;
%let ppl = population.xlsx; *大疫情系统基本信息系统导出人口数据;
%let icd = icd-10.xlsx;*icd-10分类表;
%let icdclass = code.xlsx;*三大类分类表;
%let table1 = table_ttl.csv;*大疫情系统导出死因报表卫统29-2报表合计及分性别;
%let table2 = table_male.csv;*;
%let table3 = table_female.csv;
%let rslt = rslt.rtf; *结果保存;

%let basefile = &dir&base; *11.csv文件路径;
%let pplfile = &dir&ppl;*人口文件路径;
%let icdfile = &dir&icd;*icd文件路径;
%let codefile = &dir&icdclass;*icd分类文件路径;
%let rsltfile = &dir&rslt;*结果保存路径;
%let table_ttl = &dir&table1;*卫统29-2合计及分男女文件路径;
%let table_male = &dir&table2;
%let table_female = &dir&table3;

*==============================================;
*-----------------生成死亡信息表----------------;
*==============================================;

proc import datafile="&basefile" out= work.base dbms=csv replace;
run;

data reporter.base;
    set work.base(keep = var6 var8 var11 var12 var14 
            var16 var18 var20 var22 var23 var32 var34
            var56 var57 var59 var61 var64 var66);
    rename var6 = name                       /*死者姓名*/
        var8 = gender                        /*性别*/
        var11 = day_of_birth                 /*出生日期*/
        var12 = age                          /*年龄*/
        var14 = race                         /*民族*/
        var16 = marriage                     /*婚姻状况*/
        var18 = occup                        /*个人身份*/
        var20 = edu                          /*文化程度*/
        var22 = location                     /*生前详细地址*/
        var23 = locid                        /*常住地址地区编码*/
        var32 = day_of_death                 /*死亡时间*/
        var34 = location_of_death            /*死亡地点*/
        var56 = cause_of_death               /*根本死因*/
        var57 = icd10                        /*根本死因ICD编码*/
        var59 = hospital_of_diagnosis        /*最好诊断单位*/
        var61 = diagnosis                    /*最高诊断依据*/
        var64 = report_date                  /*医生填卡日期*/
        var66 = reporter;                    /*填报单位名称*/
run;

*==============================================;
*------------------生成人口表-----------------;
*==============================================;

proc import datafile = "&pplfile" out = reporter.raw_ppl dbms = excel replace;
    getnames = yes;
run;

*==============================================;
*------------------生成标化人口表---------------;
*==============================================;

data reporter.stdppl;
    input grp  std_male std_female std_ttl;
    cards;
0   1.43    1.27    1.36 
1   1.61    1.39    1.50 
5   1.24    1.03    1.14 
10  1.78    1.50    1.64 
15  1.74    1.51    1.62 
20  1.77    1.70    1.73 
25  1.72    1.47    1.59 
30  1.39    1.36    1.38 
35  1.15    1.12    1.14 
40  0.75    0.78    0.76 
45  0.47    0.50    0.48 
50  1.02    1.17    1.09 
55  0.65    0.72    0.68 
60  0.70    0.81    0.75 
65  0.89    1.02    0.95 
70  0.73    0.78    0.76 
75  0.65    0.69    0.67 
80  0.66    0.79    0.72 
85  0.82    0.90    0.87 
;
run;

*==============================================;
*-----------------生成ICD10表-------------------;
*==============================================;

proc import datafile = "&icdfile" out = reporter.icd dbms = excel replace;
    getnames = yes;
run;

*==============================================;
*-----------------生成ICD10分类表---------------;
*==============================================;

proc import datafile = "&codefile" out = reporter.icdcode dbms = excel replace;
    getnames = yes;
run;

*==============================================;
*-------------------死因统计数据处理------------;
*==============================================;

data reporter.base2;
    set reporter.base;
        *按照常住地址提取下一级行政区,本例中是乡镇级;
/*        if index(location,"镇") > 0  then*/
/*            town = substr(location, index(location, '区')+2, index(location,"镇")-index(location, '区'));*/
/*        if index(location,"乡") > 0  then*/
/*            town = substr(location, index(location, '区')+2, index(location,"乡")-index(location, '区'));*/
/*        if index(location,"镇")+index(location,"乡") = 0 then town = "不详乡镇";*/
/*        if town = "不详乡" then town = "不详乡镇";*/
/*        rename  reporter = hospital;*/
/*        drop location ;*/
    age2 = input(scan(age,1,"岁"),3.);
        if _error_ = 1 then age2 = 0;   

    *age2 = intck('year',day_of_birth,day_of_death); /*与系统年龄计算相差较大*/
    *age2 = int(intck('month',day_of_birth,day_of_death)/12); /*与系统年龄计算有所不同*/
    *age2 = int(intck('day',day_of_birth,day_of_death)/365.25); /*与系统年龄计算相同,除非生日当天死亡会有误差*/

    if age2 = 0 then grp1 = 0;
        
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值