数据分析师 - Week15

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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容