treat | COMPLETE | SAFETY | RAND |
2 | 1 | 1 | 1 |
1 | 1 | 1 | 1 |
1 | 0 | 1 | 1 |
2 | 1 | 1 | 1 |
how to define study population using this ?
where
RAND = 1
SAFETY=1
PP=1
COMPLETE = 1
COMPLETE = 0
the output i want is
Randomized | xx (xx.x%) | xx (xx.x%) |
Safety | xx (xx.x%) | xx (xx.x%) |
Per Protocol | xx (xx.x%) | xx (xx.x%) |
Completed | xx (xx.x%) | xx (xx.x%) |
Discontinued | xx (xx.x%) | xx (xx.x%) |
What you have there is a clinical report. Your company will have specific standards, macros etc. so you should really look into that with a colleague. The code associated with created those types of outputs are proprietary so cannot be shared. You can of course do something like:
proc sql;
/* Create empty table */ create table want (co1l char(200),trt1 char(200),trt2 char(200));
/* Get treatment populations */ select count(distinct usubjid) into :t1 from have where treat=1; select count(distinct usubjid) into :t2 from have where treat=2;
/* Insert counts */ insert into want set col1="Randomized", trt1=(select strip(put(count(distinct usubjid),best.))||" ("||put((count(distinct usubjid) / &t1.)*100,4.1) from have where rand=1 and treat=1), trt2=(select strip(put(count(distinct usubjid),best.))||" ("||put((count(distinct usubjid) / &t2.)*100,4.1) from have where rand=1 and treat=2) insert into want... ; quit;
So you can do that one table in one sql like that. Mostly though that will be a long winded way of doing it. You are better off learning the specific SAS functions like freq, means, summary, and using them to get counts. Then process the output in a datastep.
I don't understand your question? And why is PP not a part of your data?
yes PP is not part if my data and the output should be 0 for that
What you have there is a clinical report. Your company will have specific standards, macros etc. so you should really look into that with a colleague. The code associated with created those types of outputs are proprietary so cannot be shared. You can of course do something like:
proc sql;
/* Create empty table */ create table want (co1l char(200),trt1 char(200),trt2 char(200));
/* Get treatment populations */ select count(distinct usubjid) into :t1 from have where treat=1; select count(distinct usubjid) into :t2 from have where treat=2;
/* Insert counts */ insert into want set col1="Randomized", trt1=(select strip(put(count(distinct usubjid),best.))||" ("||put((count(distinct usubjid) / &t1.)*100,4.1) from have where rand=1 and treat=1), trt2=(select strip(put(count(distinct usubjid),best.))||" ("||put((count(distinct usubjid) / &t2.)*100,4.1) from have where rand=1 and treat=2) insert into want... ; quit;
So you can do that one table in one sql like that. Mostly though that will be a long winded way of doing it. You are better off learning the specific SAS functions like freq, means, summary, and using them to get counts. Then process the output in a datastep.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.