SAS技术
- 用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
- 用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
网友评论