Hi to everybody,
I try to understand the final code of table 3 to understand the porcentage,
the code use a condition n(_1,t1)=.2 then.... , please check below the right expression,
but I would like to understand this " if condition n(_1,t1)=2 ", why 2?...and how can I found it in the SAS biobiography.
Thanks in advance. V
Here you are the code below, please run the code, and I want to understand the if condition n in (data total3), the way to calculate the porcentagey to calculate the:
data new;
input subjid trt fday tday;
datalines;
1 1 1 5
2 1 . 4
2 1 . 3
3 1 1 -4
3 2 1 5
4 2 1 2
4 1 1 5
;
run;
proc sql;
create table total as
select count(distinct subjid) as n, trt 'Treatment', 'number of subjects A' as col0
from new
where fday ne .
group by trt;
quit;
proc transpose data=total out=totalt;
by col0;
id trt;
var n;
run;
proc sql;
create table total2 as
select count(distinct subjid) as n, trt 'Treatment', 'number of subjects B' as col0
from new
where fday ne . and tday le 0
group by trt;
quit;
proc transpose data=total2 out=total2t;
by col0;
id trt;
var n;
run;
data total3;
length trt1 trt2 $12;
merge totalt (rename=(_1=t1 _2=t2)) total2t;
if n(_1,t1)=2 then trt1=put(_1,3.)||'
('||put((100*(_1/t1)),5.2)||'%)';
else trt1=' 0';
if n(_2,t2)=2 then trt2=put(_2,3.)||'
('||put((100*(_2/t2)),5.2)||'%)';
else trt2=' 0';
run;
The N() function counts the number of non missing arguments. So N(_1,t1) is testing that both the _1 and T1 variables are not missing.
It appears to be using this to decide whether to generate count and percentage or just to display a zero.
The N() function counts the number of non missing arguments. So N(_1,t1) is testing that both the _1 and T1 variables are not missing.
It appears to be using this to decide whether to generate count and percentage or just to display a zero.
Thank you very much Tom.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.