美文网首页
数据分析师 - Week15

数据分析师 - Week15

作者: 梁脚毛 | 来源:发表于2018-01-21 11:46 被阅读13次

    SAS技术

    1. 用tabulate制作数据透视表
    /*百分比输出格式*/
    proc format;
        picture pctfmt low-high="009.9%";
    run;
    
    proc tabulate data=sashelp.cars;
        class type;
        var invoice horsepower enginesize;
        table type all, 
            (invoice horsepower enginesize)*(mean min max) n pctn*f=pctfmt.;
    run;
    
    Result
    1. 用sql制作报表
    proc sql;
        select 
            sex,
            sum(case when weight>85 then 1 else 0 end) as weight85_cnt label="cnt weight>85",
            sum(case when weight>85 then 1 else 0 end)/count(1) as ratio label="weight>85 percent" format=percent8.2,
            sum(case when weight>95 then 1 else 0 end) as weight85_cnt label="cnt weight>95",
            sum(case when weight>95 then 1 else 0 end)/count(1) as ratio label="weight>95 percent" format=percent8.2
            
        from sashelp.class
        group by sex
        ;
    quit;
    
    Result

    相关文章

      网友评论

          本文标题:数据分析师 - Week15

          本文链接:https://www.haomeiwen.com/subject/idsfaxtx.html