SAS技術(shù)
- 用tabulate制作數(shù)據(jù)透視表
/*百分比輸出格式*/
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;
- 用sql制作報(bào)表
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;