BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aayushi_17
Quartz | Level 8
treatCOMPLETESAFETYRAND
2111
1111
1011
2111
    

 

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%)

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

I don't understand your question? And why is PP not a part of your data?

Aayushi_17
Quartz | Level 8

yes PP is not part if my data and the output should be 0 for that

error_prone
Barite | Level 11
And why proc SQL? Is this homework? If so, please post what you tried so far.
Aayushi_17
Quartz | Level 8
i have found out till this
proc sql noprint;
select count(distinct pt)
into :n1 from dispositon
where rand = 1;
select count(distinct pt)
into :n2
from dispositon
where complete = 0;
select count(distinct pt)
into :n3
from dispositon
where complete =1;
select count(distinct pt)
into :n4
from dispositon where safety = 1;
quit;

i want the seperate count when trt is 2 and 1
like
trt 1 trt2
randomized 2 2
perprotocol 0 0
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2223 views
  • 0 likes
  • 4 in conversation