计算子组的百分比使用 proc tabulate

huangapple go评论56阅读模式
英文:

Calculate the percentages by subgroups with proc tabulate

问题

I have the following table:

计算子组的百分比使用 proc tabulate

假设查看Drug3剂量为0.75和1.5。
是否可以使用proc tabulate或其他proc来计算21520 + 34732的百分比?换句话说,0.75的百分比应为21520/(21520 + 34732)=38%,1.5的百分比应为34732/(21520 + 34732)=61%。

谢谢您提前的帮助。

英文:

I have the following table:

计算子组的百分比使用 proc tabulate

Suppose to look at Drug3 dosage 0.75 and 1.5.
Is there a way with proc tabulate or another proc to compute the percentage on 21520 + 34732? In other words, the percentage for 0.75 should be 21520/(21520 + 34732)=38% and for 1.5 should be 34732/(21520 + 34732)=61%

Thank you in advance

答案1

得分: 3

以下是代码的翻译部分:

尝试多标签格式。这里是sashelp.class的示例:

proc format library=work;
  value agef (multilabel notsorted)
  11='11'
  12='12'
  13='13'
  11-13='11-13'
  14='14'
  15='15'
  16='16'
  14-16='14-16';
  value $sexf
  'F'='女性'
  'M'='男性';
  picture myPercent
  0-high = '0000009.000%';
run;

proc tabulate data=sashelp.class format=8.1;
  class age / mlf preloadfmt order=data;
  class sex;
  var height;
  table age, sex*height*(mean N colPctn*f=myPercent10.2);
  format age agef. sex $sexf.;
  title 'PROC TABULATE';
run;

这段代码来自以下文章:
https://blogs.sas.com/content/sgf/2016/12/16/creating-and-using-multilabel-formats/
其中包含了对Proc Tabulate的示例。

这种技术允许你将0.75和1.5分组到一个额外的“虚拟组”中,并获得其结果。

英文:

Try multi-label formats. Here is sashelp.class example:

proc format library=work;
  value agef (multilabel notsorted)
  11='11'
  12='12'
  13='13'
  11-13='11-13'
  14='14'
  15='15'
  16='16'
  14-16='14-16';
  value $sexf
  'F'='Female'
  'M'='Male';
  picture myPercent
  0-high = '0000009.000%';
run;

proc tabulate data=sashelp.class format=8.1;
  class age / mlf preloadfmt order=data;
  class sex;
  var height;
  table age, sex*height*(mean N colPctn*f=myPercent10.2);
  format age agef. sex $sexf.;
  title 'PROC TABULATE';
run;

Output from the code

The code is from this article about it:
https://blogs.sas.com/content/sgf/2016/12/16/creating-and-using-multilabel-formats/ with examples for Proc Tabulate.

This technique will allow you to group 0.75 and 1.5 into an additional "virtual group" and get the result for it.

huangapple
  • 本文由 发表于 2023年4月17日 18:21:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76034117.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定