印刷二维table
Printing two-dimentional table
我有一个看起来像这样的 SAS table:
Mark Country Type Count Price
1 Mark1 Country1 type1 1 1.50
2 Mark1 Country1 type2 5 21.00
3 Mark1 Country1 type3 NA NA
4 Mark2 Country2 type1 2 197.50
5 Mark2 Country2 type2 2 201.00
6 Mark2 Country2 type3 1 312.50
我需要打印二维统计数据:
Country1 Country2
Type1 ... ...
Type2 ... ...
Type3 ... ...
每次卖出的样子:price_max(count_sum)
使用 proc tabulate
在单元格中获取 price_max 非常容易
proc tabulate data=final_cars format=5.;
class type country;
var price count;
table type, country*price*max;
run;
但问题是如何在每个单元格中也放入 (count_sum)
?
如果我理解正确,你可以简单地使用 PROC SQL:
proc sql;
create table output as select distinct type,country,
put(max(price),5.)||'('||put(sum(count),5.)||')' as price_count from have
group by type,country
order by type;
quit;
proc transpose data=output out=output1;
by type;
id country;
var price_count;
run;
proc print data=output1(drop=_name_) noobs;
run;
我有一个看起来像这样的 SAS table:
Mark Country Type Count Price
1 Mark1 Country1 type1 1 1.50
2 Mark1 Country1 type2 5 21.00
3 Mark1 Country1 type3 NA NA
4 Mark2 Country2 type1 2 197.50
5 Mark2 Country2 type2 2 201.00
6 Mark2 Country2 type3 1 312.50
我需要打印二维统计数据:
Country1 Country2
Type1 ... ...
Type2 ... ...
Type3 ... ...
每次卖出的样子:price_max(count_sum)
使用 proc tabulate
在单元格中获取 price_max 非常容易proc tabulate data=final_cars format=5.;
class type country;
var price count;
table type, country*price*max;
run;
但问题是如何在每个单元格中也放入 (count_sum)
?
如果我理解正确,你可以简单地使用 PROC SQL:
proc sql;
create table output as select distinct type,country,
put(max(price),5.)||'('||put(sum(count),5.)||')' as price_count from have
group by type,country
order by type;
quit;
proc transpose data=output out=output1;
by type;
id country;
var price_count;
run;
proc print data=output1(drop=_name_) noobs;
run;