data quantify;run;
/*按人群筛选好的数据集data,where筛选出符合条件的param ,ord1为param在table中的位置*/
%macro quantify(data=,where=, param=,ord1=);
data length;
set &data.;
where aval ne . and &where.;
if find(put(aval,best.),".")=0 then do;leng=1;pleng=8.0;format pleng 4.1;end;
else do;leng=0.1**length(compress(scan(put(aval,best.),2,".")));
pleng=8+0.1*length(compress(scan(put(aval,best.),2,".")));
end;
keep parcat1 parcat2 paramcd leng pleng ;
proc sort nodupkey out=leng;by parcat1 parcat2 paramcd leng;
proc sort data=leng nodupkey;by parcat1 parcat2 paramcd ;
run;
proc sql noprint;
select leng into:leng from leng;
select pleng into:pleng from leng;
quit;
ods output summary=quantify1;
proc means data=bh(where=(&where.)) n mean std median min max ;
var aval;
run;
ods output close;
/*%put &leng. &pleng.+1;*/
data quantify2;
set quantify1 ;
n_=put(aval_n,best.);
mean_=put(round(aval_mean,&leng.),&pleng.);
median_=put(round(aval_median,&leng.),&pleng.);
std_=put(round(AVAL_StdDev,&leng.*0.1),%sysevalf(&pleng.+0.1));
min_=put(aval_min,best.);
max_=put(aval_max,best.);
array quan[6] n_ mean_ std_ median_ min_ max_;
do i=1 to 6;
quan[i]=compress(quan[i]);
end;
run;
data quantify;
length param $40;
set quantify quantify2(in=b);
if b then do;param="¶m.";ord1=&ord1.;end;
mean_std=strip(compbl(mean_||" ("||compress(std_||")"))) ;
min_max=compbl(strip(min_||" - "||max_));
if cmiss(n_, mean_, std_, median_, min_, max_)=6 then delete;
proc sort;by ord1 param ;
run;
%mend;
%quantify(data=bh,where=paramcd="COURSE" and parcat1="" and parcat2="",param=病程(月)[1],ord1=1);
统计描述——定量资料
最新推荐文章于 2022-08-11 15:32:07 发布