Help using Base SAS procedures

how to simplify the code to produce a table

Reply
Super Contributor
Posts: 272

how to simplify the code to produce a table

Dear,

 

In my AE data the folowing information is given.

 

ID    PERIOD      DOSE     AEREL                                 TRTEMFL

1         1                 25        RELATED                                  Y

1          2                25        

2         1                 50         RELATED                                 Y

2          2                50                   

3          1                25          

4          1                25

5           1                50

6           1                25           RELATED                               Y

7           1                 25          NOTRELATED                        Y

8            1               25               

 

 

OUTPUT NEED

 

                                                  Period1

                                    ______________________

                                      75                                 50

NS %                              N=6                              N=2   

ANY TEAE                     3(50)                              1(50)

     Related                     2(33.3)                           1(50)

 

My code;

 

proc sql;
create table TotalNS as
select count(distinct usubjid) as NS
from data1
where dose =25 and period=1;
quit;

 


proc sql;
create table one as
select count(distinct usubjid) as NS
from adae
where trtemfl='Y' and dose =25 and period=1; ;
quit;

 

proc sql;
create table three as
select count(distinct usubjid) as NS
from adae
where trtemfl='Y' and dose =25 and period=1 and arel='RELATED';
quit;

 

 

I created these three datasets and merged the them. Is there any way  I can simplify my code and calculate all in one.  There are several doses inaddition to 25 and 50 to calclate.

Thanks

 

Super User
Posts: 17,912

Re: how to simplify the code to produce a table

You should provide your data as a data step, not just text Smiley Happy

 

I don't think you can via SQL, but you probably can via a data step. 

 

The count distinct does make it a bit harder, but try using BY GROUPS with First/Last logic to do counts. Or even proc freqs if you structure your data correctly - mainly so you only have one per person.

Ask a Question
Discussion stats
  • 1 reply
  • 185 views
  • 0 likes
  • 2 in conversation