【问题标题】:Printing two-dimentional table [duplicate]打印二维表[重复]
【发布时间】:2020-11-16 22:44:26
【问题描述】:

我有一个看起来像这样的 SAS 表:

  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 REPORT。请参阅您之前的问题中的第二个答案stackoverflow.com/questions/64838455/…
  • @Richard 谢谢!但问题是在 proc 报告中合并价格和计数,以便它们在一个单元格中,如“price_min(count_sum)”。可以在 REPORT 中使用吗?我还看到 proc 报告给出了总和报告,但没有给出最大值。
  • 在 SAS 中有 SUM 统计数据的地方,请放心,所有统计数据 ae 也可用。 REPORT 可以在特殊用途需要时计算一个值
  • 有时您需要单独计算多值聚合单元,只需 Proc PRINT 即可。用更新的 a 查看你原来的 q

标签: sas proc tabulate


【解决方案1】:

如果我理解正确,您可以简单地使用 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;

【讨论】:

    猜你喜欢
    • 2014-02-01
    • 2014-09-03
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多