之前文章SAS编程-Table:层级拼接法输出AE SOC、PT的受试者发生率,介绍了SOC、PT的嵌套表格的处理。思路是,将SOC和PT变量的信息,整合到一个变量中,通过一个变量进行计数处理。
有个读者留言问,“2层的话怎么做,就是求ae pt的严重程度”,他问的应该是PT与Severity的嵌套如何输出。如果使用层级拼接法来处理的话,这与SOC、PT与Severity的3层嵌套过程大体相同。这篇文章,介绍这个3层嵌套的处理过程。更多临床试验SAS编程内容,欢迎关注:SAS茶谈。
首先,需要明确,添加SEV的嵌套与之前SOC、PT的嵌套是不同的。对于SEV的各类别信息,不管是否存在都需要将类别完全展示(如上图);而SOC、PT的嵌套只需展示数据集既有的记录。
以上意味着,我们需要将可能不全的SEV信息全部展示。所以,像之前将三个变量转化为单个变量进行处理,是不方便实现既定输出的。
但由于SOC、PT的信息是直接展示数据中已有的记录,我们是完全可以利用层级拼接将SOC、PT整合成一个变量(如之前文章介绍),然后将SEV的另做为分析分组变量进行处理。为显示SEV的所有类别,在Means过程步中可以使用preloadfmt
选项进行嵌套。
具体思路如上,代码实现过程比前文多了一个分析分组变量sev
以及对应的Format设置(class sevdisn/preloadfmt mlf order = data ;
)。
程序附下文,代码中Sevdisn保留了Missing的记录(sevdisn=99
),如果Missing行各组计数都为0,记录一般会删除。生成SEV的Preloadfmt时,添加了一个汇总行(1-3, 99 = 0
),是为了输出上一层嵌套类别的计数(如shell中的 SOC #1、PT #1行)。
这里就不对代码进行详细运行解释,具体步骤可以参考前文解释,若有疑问,欢迎评论区讨论。
***1. Create formats for output;
**1.1 Format for Statistics;
proc format ;
*Format for FREQ;
picture freq (round default=8 )
0 <-<9.95 = "009.9)" (prefix="( " )
9.95 -<99.5 = "009.9)" (prefix="( " )
99.5-100 = "(100) " (noedit)
;
*Format for trt;
value trt01an
1 = 1
2 = 2
3 = 3
;
*Format for sev display num;
value sevdisn(notsorted multilabel)
1-3,99 = 0
1 = 1
2 = 2
3 = 3
99 = 99
;
value $sevdis
"1" = "Severe"
"2" = "Moderate"
"3" = "Mild"
"99" = "Missing"
;
run;
***2. Get data for analysis;
**2.1 Get data for BigN;
data adsl;
set adam.adsl;
flag = 1;
where saffl = "Y";
proc sort;
by usubjid;
run;
**2.2 Get data for small n;
data adae;
merge adam.adae(in = a where=(aecat = "")) adsl(in = b);
by usubjid;
if a and b;
*Set for missing values;
if missing(aebodsys) then aebodsys = "Missing system organ class";
if missing(aedecod) then aedecod = "Missing preferred term";
*SEV display num;
if aesevn = 1 then sevdisn = 3;
else if aesevn = 2 then sevdisn = 2;
else if aesevn = 3 then sevdisn = 1;
else sevdisn = 99;
*Combine all categories in one variable;
length cat $200;
cat = "01!"||"Subjects with at least one AE"; output;
cat = "02!"||strip(aebodsys); output;
cat = "02!"||strip(aebodsys)||"!"||strip(aedecod); output;
proc sort nodupkey;
by cat usubjid;
run;
***3. Calculate statistics;
**3.1 Derive BigN and save them to macro vars;
proc means data = adsl nway;
class trt01an;
var flag;
output n = bign nmiss = nmiss out = BigN;
run;
data _null_;
set BigN;
call symput("N_"||strip(put(trt01an, best.)), strip(put(bign, best.)));
run;
*Check BigN;
proc sql noprint;
create table BigNcheck as
select *
from dictionary.macros
where name like "N_%";
quit;
**3.2 Derive statistic vars;
proc means data = adae noprint nway completetypes;
format trt01an trt01an.;
class trt01an /preloadfmt order = data ;
class cat;
format sevdisn sevdisn.;
class sevdisn/preloadfmt mlf order = data ;
var flag;
output n=count nmiss=nmiss out=count1 ;
run;
data count2;
merge count1(in = a) bign;
by trt01an;
length freq $200;
if count = 0 then freq =strip(put(count, best.));
else freq =strip(put(count, best.))||put(count/bign*100, freq.);
if a;
proc sort;
by cat sevdisn trt01an;
run;
proc transpose data = count2 out = count3 prefix = trt_;
by cat sevdisn;
id trt01an;
var freq;
run;
以上输出程序输出的数据集如下,
感谢阅读, 欢迎关注:SAS茶谈!
若有疑问,欢迎评论交流!
相关阅读:
SAS编程-Table:频数汇总表的总结
SAS编程-Table:层级关系的频数汇总处理 ——层级拼接法
SAS编程-Table:层级拼接法输出AE SOC、PT的受试者发生率