240.ADVERSE EVENT SUMMARY TABLE WITH PERCENTAGE DISTRIBUTION ACROSS TREATMENT GROUPS USING DATA STEP IN SAS

ADVERSE EVENT SUMMARY TABLE WITH PERCENTAGE DISTRIBUTION ACROSS TREATMENT GROUPS USING DATA STEP IN SAS

options nocenter;

1.Mock Data

data ae;

  input STUDYID $ USUBJID $ TRT01P $ AEDECOD $ AESER $;

  datalines;

C001 001 Placebo Headache N

C001 002 DrugA Headache N

C001 003 DrugA Nausea N

C001 004 DrugB Headache Y

C001 005 Placebo Dizziness N

C001 006 DrugA Headache Y

C001 007 DrugB Nausea N

C001 008 Placebo Nausea N

C001 009 DrugB Dizziness Y

C001 010 DrugA Dizziness N

;

run;

proc print;run;

Output:

Obs STUDYID USUBJID TRT01P AEDECOD AESER
1 C001 001 Placebo Headache N
2 C001 002 DrugA Headache N
3 C001 003 DrugA Nausea N
4 C001 004 DrugB Headache Y
5 C001 005 Placebo Dizzines N
6 C001 006 DrugA Headache Y
7 C001 007 DrugB Nausea N
8 C001 008 Placebo Nausea N
9 C001 009 DrugB Dizzines Y
10 C001 010 DrugA Dizzines N


2.Create Subject-Level Count by Treatment

proc sql;

  create table subj_n as

  select TRT01P, count(distinct USUBJID) as N

  from ae

  group by TRT01P;

quit;

proc print;run;

Output:

Obs TRT01P N
1 DrugA 4
2 DrugB 3
3 Placebo 3


3.Transpose AE Counts to Table Format

/* Step 1: Create ae_summary using PROC SQL */

proc sql;

  create table ae_summary as

  select AEDECOD, TRT01P,

         count(distinct USUBJID) as AE_Count

  from ae

  group by AEDECOD, TRT01P;

quit;

proc print;run;

Output:

Obs AEDECOD TRT01P AE_Count
1 Dizzines DrugA 1
2 Dizzines DrugB 1
3 Dizzines Placebo 1
4 Headache DrugA 2
5 Headache DrugB 1
6 Headache Placebo 1
7 Nausea DrugA 1
8 Nausea DrugB 1
9 Nausea Placebo 1


/* Step 2: Transpose the table to show treatment groups horizontally */

proc transpose data=ae_summary out=ae_trans prefix=Count_;

  by AEDECOD;

  id TRT01P;

  var AE_Count;

run;

proc print;run;

Output:

Obs AEDECOD _NAME_ Count_DrugA Count_DrugB Count_Placebo
1 Dizzines AE_Count 1 1 1
2 Headache AE_Count 2 1 1
3 Nausea AE_Count 1 1 1


4.Merge with Subject Counts and Calculate Percentages

data final_table;

  set ae_trans;


  format Headline $200.;


  Headline = catx(' ',

                 AEDECOD,

                 put(Count_Placebo, 3.), '(', put(Count_Placebo/50*100, 4.1), '%)',

                 put(Count_DrugA, 3.),   '(', put(Count_DrugA/60*100, 4.1), '%)',

                 put(Count_DrugB, 3.),   '(', put(Count_DrugB/55*100, 4.1), '%)'

                 );

run;

proc print;run;

Output:

Obs AEDECOD _NAME_ Count_DrugA Count_DrugB Count_Placebo Headline
1 Dizzines AE_Count 1 1 1 Dizzines 1 ( 2.0 %) 1 ( 1.7 %) 1 ( 1.8 %)
2 Headache AE_Count 2 1 1 Headache 1 ( 2.0 %) 2 ( 3.3 %) 1 ( 1.8 %)
3 Nausea AE_Count 1 1 1 Nausea 1 ( 2.0 %) 1 ( 1.7 %) 1 ( 1.8 %)


5.Print the Final Table

proc print data=final_table noobs label;

  var Headline;

  label Headline = "Adverse Event Summary by Treatment (%)";

run;

Output:

Adverse Event Summary by Treatment (%)
Dizzines 1 ( 2.0 %) 1 ( 1.7 %) 1 ( 1.8 %)
Headache 1 ( 2.0 %) 2 ( 3.3 %) 1 ( 1.8 %)
Nausea 1 ( 2.0 %) 1 ( 1.7 %) 1 ( 1.8 %)


6.Listing Code

proc sort data=ae; by TRT01P AEDECOD USUBJID; run;

proc print;run;

Output:

Obs STUDYID USUBJID TRT01P AEDECOD AESER
1 C001 010 DrugA Dizzines N
2 C001 002 DrugA Headache N
3 C001 006 DrugA Headache Y
4 C001 003 DrugA Nausea N
5 C001 009 DrugB Dizzines Y
6 C001 004 DrugB Headache Y
7 C001 007 DrugB Nausea N
8 C001 005 Placebo Dizzines N
9 C001 001 Placebo Headache N
10 C001 008 Placebo Nausea N


proc print data=ae label noobs;

  var USUBJID TRT01P AEDECOD AESER;

  label USUBJID="Subject ID"

        TRT01P="Treatment"

        AEDECOD="Adverse Event"

        AESER="Serious (Y/N)";

run;

Output:
Subject ID Treatment Adverse Event Serious
(Y/N)
010 DrugA Dizzines N
002 DrugA Headache N
006 DrugA Headache Y
003 DrugA Nausea N
009 DrugB Dizzines Y
004 DrugB Headache Y
007 DrugB Nausea N
005 Placebo Dizzines N
001 Placebo Headache N
008 Placebo Nausea N






To Visit My Previous E-Commerce Dataset:Click Here
To Visit My Previous Length,Input,Retain Statements:Click Here
To Visit My Previous Urban Traffic Dataset:Click Here
To Visit My Previous Home Energy Consumption Dataset:Click Here





--->PLEASE FOLLOW OUR BLOG FOR MORE INFORMATION.
--->PLEASE DO COMMENTS AND SHARE OUR BLOG.

PLEASE FOLLOW OUR TELEGRAM CHANNEL CLICK HERE

PLEASE FOLLOW OUR FACEBOOK PAGE  CLICK HERE

PLEASE FOLLOW OUR INSTAGRAM PAGE CLICK HERE







Comments