Monday, 31 March 2025

141.COMPREHENSIVE ANALYSIS AND STATISTICAL EVALUATION OF CLINICAL TRIAL DATA INCLUDING DEMOGRAPHICS | TREATMENT RESPONSES | ADVERSE EVENTS AND CHRONIC CONDITIONS

COMPREHENSIVE ANALYSIS AND STATISTICAL EVALUATION OF CLINICAL TRIAL DATA INCLUDING DEMOGRAPHICS | TREATMENT RESPONSES | ADVERSE EVENTS AND CHRONIC CONDITIONS


 /* Step 1: Creating a Clinical Trial Dataset */

DATA Clinical_Trial_Data;

    LENGTH Patient_ID $10 Gender $6 Drug_Name $15 Adverse_Event $20;

    FORMAT Age 8. Drug_Dosage 8.1 Response_Score 8.2;

    DO i = 1 TO 10;

        Patient_ID = CAT('P', PUT(i, Z4.));

        Age = 18 + INT(RANUNI(1234)*62);

        /*Gender using IF-ELSE */

        IF INT(RANUNI(1234)*2) = 0 THEN Gender = 'Male';

        ELSE Gender = 'Female';

        

        /*Drug_Name using IF-ELSE*/

        IF INT(RANUNI(1234)*5) = 0 THEN Drug_Name = 'Drug_A';

        ELSE IF INT(RANUNI(1234)*5) = 1 THEN Drug_Name = 'Drug_B';

        ELSE IF INT(RANUNI(1234)*5) = 2 THEN Drug_Name = 'Drug_C';

        ELSE IF INT(RANUNI(1234)*5) = 3 THEN Drug_Name = 'Drug_D';

        ELSE Drug_Name = 'Drug_E';

        

        Drug_Dosage = 50 + INT(RANUNI(1234)*150); /* Dosage between 50mg and 200mg */

        Response_Score = ROUND(RANUNI(1234)*100, 0.1); /* Score from 0 to 100 */

        

        /*Adverse_Event using IF-ELSE*/

        IF INT(RANUNI(1234)*6) = 0 THEN Adverse_Event = 'None';

        ELSE IF INT(RANUNI(1234)*6) = 1 THEN Adverse_Event = 'Headache';

        ELSE IF INT(RANUNI(1234)*6) = 2 THEN Adverse_Event = 'Nausea';

        ELSE IF INT(RANUNI(1234)*6) = 3 THEN Adverse_Event = 'Dizziness';

        ELSE IF INT(RANUNI(1234)*6) = 4 THEN Adverse_Event = 'Fatigue';

        ELSE Adverse_Event = 'Insomnia';

        

        OUTPUT;

    END;

DROP i;

RUN;

PROC PRINT;RUN;


OUTPUT:

Obs Patient_ID Gender Drug_Name Adverse_Event Age Drug_Dosage Response_Score
1 P0001 Male Drug_E Insomnia 33 55.0 10.80
2 P0002 Female Drug_E Headache 74 126.0 28.40
3 P0003 Male Drug_C Dizziness 45 185.0 23.40
4 P0004 Female Drug_C Nausea 57 113.0 49.30
5 P0005 Female Drug_A Headache 29 97.0 96.60
6 P0006 Female Drug_E Fatigue 58 91.0 72.80
7 P0007 Male Drug_C Insomnia 38 74.0 83.00
8 P0008 Female Drug_B Insomnia 35 94.0 36.60
9 P0009 Female Drug_C Insomnia 20 51.0 94.20
10 P0010 Male Drug_D None 69 193.0 73.00


/* Step 2: Additional Patient Information */

DATA Clinical_Trial_Data;

   RETAIN Patient_ID Gender Drug_Name Adverse_Event Age Drug_Dosage Response_Score         BMI Smoker_Status;

    LENGTH Chronic_Condition $18;

    SET Clinical_Trial_Data;

    

    /*BMI generation */

    BMI = ROUND(18 + RANUNI(1234)*12, 1); /* BMI between 18 and 30 */

    

    /*Smoker_Status assignment using IF-ELSE */

    IF INT(RANUNI(1234)*2) = 0 THEN Smoker_Status = 'Non-Smoker';

    ELSE Smoker_Status = 'Smoker';

    

    /*Chronic_Condition assignment using IF-ELSE */

    IF INT(RANUNI(1234)*3) = 0 THEN Chronic_Condition = 'None';

    ELSE IF INT(RANUNI(1234)*3) = 1 THEN Chronic_Condition = 'Hypertension';

    ELSE Chronic_Condition = 'Diabetes';

RUN;

PROC PRINT;RUN;


OUTPUT:

Obs Patient_ID Gender Drug_Name Adverse_Event Age Drug_Dosage Response_Score BMI Smoker_Status Chronic_Condition
1 P0001 Male Drug_E Insomnia 33 55.0 10.80 21 Non-Smoker Diabetes
2 P0002 Female Drug_E Headache 74 126.0 28.40 21 Non-Smoker None
3 P0003 Male Drug_C Dizziness 45 185.0 23.40 19 Non-Smoker None
4 P0004 Female Drug_C Nausea 57 113.0 49.30 18 Non-Smoker None
5 P0005 Female Drug_A Headache 29 97.0 96.60 29 Smoker Hypertension
6 P0006 Female Drug_E Fatigue 58 91.0 72.80 22 Non-Smoker Diabetes
7 P0007 Male Drug_C Insomnia 38 74.0 83.00 22 Non-Smoker Diabetes
8 P0008 Female Drug_B Insomnia 35 94.0 36.60 27 Non-Smoker Diabetes
9 P0009 Female Drug_C Insomnia 20 51.0 94.20 21 Smoker None
10 P0010 Male Drug_D None 69 193.0 73.00 19 Smoker Diabetes


/* Step 3: Analyzing Data Using Various SAS Procedures */


/* Summary Statistics of Age, Drug Dosage, and Response Score */

PROC MEANS DATA=Clinical_Trial_Data N MEAN MEDIAN MIN MAX STDDEV;

    VAR Age Drug_Dosage Response_Score BMI;

RUN;


OUTPUT:

                                                                   The MEANS Procedure

Variable N Mean Median Minimum Maximum Std Dev
Age
Drug_Dosage
Response_Score
BMI
10
10
10
10
45.8000000
107.9000000
56.8100000
21.9000000
41.5000000
95.5000000
61.0500000
21.0000000
20.0000000
51.0000000
10.8000000
18.0000000
74.0000000
193.0000000
96.6000000
29.0000000
17.9431200
48.6745427
31.0735490
3.5103023


/* Frequency Distribution of Gender, Drug Name, and Adverse Events */

PROC FREQ DATA=Clinical_Trial_Data;

    TABLES Gender Adverse_Event Drug_Name Drug_Dosage Smoker_Status Chronic_Condition / NOCUM NOROW NOCOL;

RUN;


OUTPUT:

                                                                 The FREQ Procedure

Gender Frequency Percent
Female 6 60.00
Male 4 40.00


Adverse_Event Frequency Percent
Dizziness 1 10.00
Fatigue 1 10.00
Headache 2 20.00
Insomnia 4 40.00
Nausea 1 10.00
None 1 10.00


Drug_Name Frequency Percent
Drug_A 1 10.00
Drug_B 1 10.00
Drug_C 4 40.00
Drug_D 1 10.00
Drug_E 3 30.00


Drug_Dosage Frequency Percent
51.0 1 10.00
55.0 1 10.00
74.0 1 10.00
91.0 1 10.00
94.0 1 10.00
97.0 1 10.00
113.0 1 10.00
126.0 1 10.00
185.0 1 10.00
193.0 1 10.00


Smoker_Status Frequency Percent
Non-Smoker 7 70.00
Smoker 3 30.00


Chronic_Condition Frequency Percent
Diabetes 5 50.00
Hypertension 1 10.00
None 4 40.00


/* Crosstab Analysis of Smoking and Chronic Conditions */

PROC FREQ DATA=Clinical_Trial_Data;

    TABLES Smoker_Status*Chronic_Condition / CHISQ; 

RUN;


OUTPUT:

                                                                              The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of Smoker_Status by Chronic_Condition
Smoker_Status Chronic_Condition
Diabetes Hypertension None Total
Non-Smoker
4
40.00
57.14
80.00
0
0.00
0.00
0.00
3
30.00
42.86
75.00
7
70.00
 
 
Smoker
1
10.00
33.33
20.00
1
10.00
33.33
100.00
1
10.00
33.33
25.00
3
30.00
 
 
Total
5
50.00
1
10.00
4
40.00
10
100.00



Statistics for Table of Smoker_Status by Chronic_Condition

Statistic DF Value Prob
Chi-Square 2 2.6190 0.2699
Likelihood Ratio Chi-Square 2 2.7146 0.2574
Mantel-Haenszel Chi-Square 1 0.0433 0.8351
Phi Coefficient   0.5118  
Contingency Coefficient   0.4556  
Cramer's V   0.5118  
WARNING: 100% of the cells have expected counts less
than 5. Chi-Square may not be a valid test.



Sample Size = 10


/* Generating a Detailed Report */

PROC REPORT DATA=Clinical_Trial_Data NOWD;

    COLUMNS Patient_ID Age Gender Drug_Name Drug_Dosage Response_Score Adverse_Event BMI Smoker_Status Chronic_Condition;

    DEFINE Patient_ID / DISPLAY 'Patient ID';

    DEFINE Age / ANALYSIS 'Age' MEAN;

    DEFINE Gender / GROUP 'Gender';

    DEFINE Drug_Name / GROUP 'Drug Name';

    DEFINE Drug_Dosage / ANALYSIS 'Dosage (mg)' MEAN;

    DEFINE Response_Score / ANALYSIS 'Response Score' MEAN;

    DEFINE Adverse_Event / GROUP 'Adverse Event';

    DEFINE BMI / ANALYSIS 'BMI' MEAN;

    DEFINE Smoker_Status / GROUP 'Smoking Status';

    DEFINE Chronic_Condition / GROUP 'Chronic Condition';

RUN;


OUTPUT:

Patient ID Age Gender Drug Name Dosage (mg) Response Score Adverse Event BMI Smoking Status Chronic Condition
P0005 29 Female Drug_A 97.0 96.60 Headache 29 Smoker Hypertension
P0008 35   Drug_B 94.0 36.60 Insomnia 27 Non-Smoker Diabetes
P0009 20   Drug_C 51.0 94.20 Insomnia 21 Smoker None
P0004 57     113.0 49.30 Nausea 18 Non-Smoker None
P0006 58   Drug_E 91.0 72.80 Fatigue 22 Non-Smoker Diabetes
P0002 74     126.0 28.40 Headache 21 Non-Smoker None
P0003 45 Male Drug_C 185.0 23.40 Dizziness 19 Non-Smoker None
P0007 38     74.0 83.00 Insomnia 22 Non-Smoker Diabetes
P0010 69   Drug_D 193.0 73.00 None 19 Smoker Diabetes
P0001 33   Drug_E 55.0 10.80 Insomnia 21 Non-Smoker Diabetes


/* Additional Analysis: Impact of Smoking on Response */

PROC TTEST DATA=Clinical_Trial_Data;

    CLASS Smoker_Status;

    VAR Response_Score;

    TITLE 'T-Test for Response Score by Smoking Status';

RUN;


OUTPUT:

                                        T-Test for Response Score by Smoking Status
                                                   The TTEST Procedure
 
                                               Variable: Response_Score

Smoker_Status N Mean Std Dev Std Err Minimum Maximum
Non-Smoker 7 43.4714 26.4616 10.0015 10.8000 83.0000
Smoker 3 87.9333 12.9882 7.4987 73.0000 96.6000
Diff (1-2)   -44.4619 23.8188 16.4365    


/* Predicting Response Score Using Multiple Factors */

PROC REG DATA=Clinical_Trial_Data;

    MODEL Response_Score = Age Drug_Dosage BMI;

    TITLE 'Multiple Regression Analysis';

RUN;


OUTPUT:

                                                       Multiple Regression Analysis
                                                          The REG Procedure
                                                            Model: MODEL1
                                               Dependent Variable: Response_Score

Number of Observations Read 10
Number of Observations Used 10


Analysis of Variance
Source DF Sum of
Squares
Mean
Square
F Value Pr > F
Model 3 953.72581 317.90860 0.25 0.8611
Error 6 7736.36319 1289.39387    
Corrected Total 9 8690.08900      


/* Response Score by Chronic Condition */

PROC MEANS DATA=Clinical_Trial_Data;

    CLASS Chronic_Condition;

    VAR Response_Score;

RUN;


OUTPUT:

                                                                   The MEANS Procedure

Analysis Variable : Response_Score
Chronic_Condition N Obs N Mean Std Dev Minimum Maximum
Diabetes 5 5 55.2400000 30.4825852 10.8000000 83.0000000
Hypertension 1 1 96.6000000 . 96.6000000 96.6000000
None 4 4 48.8250000 32.2631239 23.4000000 94.2000000


/* Identifying Patients with Severe Side Effects */

PROC SQL;

    SELECT Patient_ID, Drug_Name, Adverse_Event, Smoker_Status, Chronic_Condition

    FROM Clinical_Trial_Data

    WHERE Adverse_Event IN ('Dizziness', 'Fatigue', 'Insomnia')

    ORDER BY Drug_Name;

QUIT;


OUTPUT:

Patient_ID Drug_Name Adverse_Event Smoker_Status Chronic_Condition
P0008 Drug_B Insomnia Non-Smoker Diabetes
P0009 Drug_C Insomnia Smoker None
P0003 Drug_C Dizziness Non-Smoker None
P0007 Drug_C Insomnia Non-Smoker Diabetes
P0001 Drug_E Insomnia Non-Smoker Diabetes
P0006 Drug_E Fatigue Non-Smoker Diabetes


/* Scatter Plot: Age vs. Response Score */

PROC SGPLOT DATA=Clinical_Trial_Data;

    SCATTER X=Age Y=Response_Score / GROUP=Drug_Name;

    TITLE 'Scatter Plot of Age vs. Response Score by Drug';

RUN;


/* New Data Analysis for High Responders */

DATA High_Responders;

    SET Clinical_Trial_Data;

    IF Response_Score > 85;

RUN;

PROC PRINT DATA=High_Responders;

    TITLE 'Patients with High Response Scores';

RUN;


OUTPUT:        

                                                                 Patients with High Response Scores

Obs Patient_ID Gender Drug_Name Adverse_Event Age Drug_Dosage Response_Score BMI Smoker_Status Chronic_Condition
1 P0005 Female Drug_A Headache 29 97.0 96.60 29 Smoker Hypertension
2 P0009 Female Drug_C Insomnia 20 51.0 94.20 21 Smoker None


/* Final Analysis: Response by Drug and Age Group */

PROC MEANS DATA=Clinical_Trial_Data;

    CLASS Drug_Name Age Chronic_Condition;

    VAR Response_Score;

    TITLE 'Response Score by Drug, Age , and Chronic Condition';

RUN;


OUTPUT:

                                        Response Score by Drug, Age, and Chronic Condition

                                                             The MEANS Procedure

Analysis Variable : Response_Score
Drug_Name Age Chronic_Condition N Obs N Mean Std Dev Minimum Maximum
Drug_A 29 Hypertension 1 1 96.6000000 . 96.6000000 96.6000000
Drug_B 35 Diabetes 1 1 36.6000000 . 36.6000000 36.6000000
Drug_C 20 None 1 1 94.2000000 . 94.2000000 94.2000000
  38 Diabetes 1 1 83.0000000 . 83.0000000 83.0000000
  45 None 1 1 23.4000000 . 23.4000000 23.4000000
  57 None 1 1 49.3000000 . 49.3000000 49.3000000
Drug_D 69 Diabetes 1 1 73.0000000 . 73.0000000 73.0000000
Drug_E 33 Diabetes 1 1 10.8000000 . 10.8000000 10.8000000
  58 Diabetes 1 1 72.8000000 . 72.8000000 72.8000000
  74 None 1 1 28.4000000 . 28.4000000 28.4000000


PRACTICE AND COMMENT YOUR CODE: 

-->PLEASE FOLLOW OUR BLOG FOR MORE UPDATES.

TO FOLLOW OUR TELEGRAM CHANNEL CLICK HERE


Sunday, 30 March 2025

140.SAS CLINICAL ANALYSIS USING DATA, PROC MEANS, PROC FREQ, PROC UNIVARIATE, PROC CORR, PROC REPORT, PROC SQL, PROC SGPLOT, AND PROC EXPORT

SAS CLINICAL ANALYSIS USING DATA, PROC MEANS, PROC FREQ, PROC UNIVARIATE, PROC CORR, PROC REPORT, PROC SQL, PROC SGPLOT, AND PROC EXPORT


 /* Step 1: Creating the Clinical Trial Dataset */

DATA Clinical_Trials;

    LENGTH Trial_ID $10 Patient_ID $10 Gender $6 Drug_Name $15 Side_Effects $20 Outcome $10;

    FORMAT Age 8. Dosage_mg 8.2 Efficacy 8.2 BP_Change 8.2 Recovery_Time 8.2 Weight_Change 8.2 Heart_Rate 8.2 Cholesterol_Level 8.2;


    DO Trial_Index = 1001 TO 1005;

        Trial_ID = CATS("T", Trial_Index);


        DO Patient_Index = 2001 TO 2005; 

            Patient_ID = CATS("P", Patient_Index);


            Age = ROUND(18 + RANUNI(1234) * 62, 1); /* Age between 18 and 80 */


            Gender_Val = INT(RANUNI(1234) * 2) + 1;

            SELECT (Gender_Val);

                WHEN (1) Gender = "Male";

                WHEN (2) Gender = "Female";

                OTHERWISE Gender = "Unknown";

            END;


            /* Assigning Drug Name */

            Drug_Num = INT(RANUNI(1234) * 5) + 1;

            SELECT (Drug_Num);

                WHEN (1) Drug_Name = "DrugA";

                WHEN (2) Drug_Name = "DrugB";

                WHEN (3) Drug_Name = "DrugC";

                WHEN (4) Drug_Name = "DrugD";

                WHEN (5) Drug_Name = "DrugE";

                OTHERWISE Drug_Name = "Unknown";

            END;


            Dosage_mg = ROUND(50 + RANUNI(1234) * 250, 1); /* Dosage between 50 and 300mg */

            Efficacy = ROUND(RANUNI(1234) * 100, 1); /* Efficacy between 0-100% */


\

            Side_Num = INT(RANUNI(1234) * 6) + 1;

            SELECT (Side_Num);

                WHEN (1) Side_Effects = "None";

                WHEN (2) Side_Effects = "Nausea";

                WHEN (3) Side_Effects = "Dizziness";

                WHEN (4) Side_Effects = "Headache";

                WHEN (5) Side_Effects = "Fatigue";

                WHEN (6) Side_Effects = "Insomnia";

                OTHERWISE Side_Effects = "Unknown";

            END;


            BP_Change = ROUND(-15 + RANUNI(1234) * 30, 1); /* BP change between -15 and 15 */

            Recovery_Time = ROUND(5 + RANUNI(1234) * 30, 1); /* Recovery time between 5 and 35 days */

            Weight_Change = ROUND(-10 + RANUNI(1234) * 20, 1); /* Weight change between -10 and 10 kg */

            Heart_Rate = ROUND(60 + RANUNI(1234) * 40, 1); /* Heart rate between 60 and 100 bpm */

            Cholesterol_Level = ROUND(150 + RANUNI(1234) * 100, 1); /* Cholesterol level between 150 and 250 */


            IF Efficacy > 50 THEN Outcome = "Success";

            ELSE Outcome = "Failure";


            OUTPUT;

        END;

    END;

RUN;

PROC PRINT;RUN;


OUTPUT:

Obs Trial_ID Patient_ID Gender Drug_Name Side_Effects Outcome Age Dosage_mg Efficacy BP_Change Recovery_Time Weight_Change Heart_Rate Cholesterol_Level Trial_Index Patient_Index Gender_Val Drug_Num Side_Num
1 T1001 P2001 Male DrugB None Failure 33 74.00 26.00 -14.00 8.00 -1.00 66.00 154.00 1001 2001 1 2 1
2 T1001 P2002 Male DrugE Dizziness Success 46 292.00 74.00 -4.00 15.00 0.00 71.00 185.00 1001 2002 1 5 3
3 T1001 P2003 Male DrugA Headache Failure 34 228.00 0.00 12.00 12.00 6.00 66.00 162.00 1001 2003 1 1 4
4 T1001 P2004 Female DrugD Headache Success 51 187.00 98.00 -2.00 20.00 9.00 88.00 185.00 1001 2004 2 4 4
5 T1001 P2005 Female DrugA Headache Success 29 129.00 97.00 -6.00 25.00 1.00 88.00 210.00 1001 2005 2 1 4
6 T1002 P2001 Male DrugB Headache Success 33 232.00 92.00 6.00 6.00 4.00 74.00 186.00 1002 2001 1 2 4
7 T1002 P2002 Female DrugC Fatigue Success 50 91.00 83.00 -10.00 21.00 -2.00 96.00 177.00 1002 2002 2 3 5
8 T1002 P2003 Male DrugB Headache Failure 55 124.00 37.00 15.00 8.00 8.00 62.00 155.00 1002 2003 1 2 4
9 T1002 P2004 Female DrugE Insomnia Failure 67 153.00 1.00 14.00 7.00 9.00 95.00 167.00 1002 2004 2 5 6
10 T1002 P2005 Male DrugE Headache Success 69 77.00 75.00 14.00 27.00 -7.00 82.00 242.00 1002 2005 1 5 4
11 T1003 P2001 Male DrugE Fatigue Success 36 232.00 56.00 12.00 31.00 -7.00 76.00 195.00 1003 2001 1 5 5
12 T1003 P2002 Male DrugA None Success 33 240.00 61.00 1.00 10.00 -5.00 92.00 220.00 1003 2002 1 1 1
13 T1003 P2003 Female DrugE Insomnia Failure 78 162.00 48.00 -10.00 29.00 1.00 63.00 216.00 1003 2003 2 5 6
14 T1003 P2004 Male DrugD None Failure 64 266.00 6.00 -9.00 28.00 -8.00 79.00 158.00 1003 2004 1 4 1
15 T1003 P2005 Female DrugC Dizziness Failure 77 163.00 8.00 -8.00 20.00 5.00 90.00 239.00 1003 2005 2 3 3
16 T1004 P2001 Female DrugD Dizziness Success 23 147.00 84.00 8.00 19.00 4.00 87.00 228.00 1004 2001 2 4 3
17 T1004 P2002 Female DrugE Nausea Success 47 215.00 55.00 -4.00 9.00 0.00 61.00 214.00 1004 2002 2 5 2
18 T1004 P2003 Female DrugC Dizziness Failure 72 83.00 33.00 13.00 6.00 -2.00 68.00 155.00 1004 2003 2 3 3
19 T1004 P2004 Female DrugD Dizziness Success 56 175.00 53.00 4.00 32.00 5.00 72.00 203.00 1004 2004 2 4 3
20 T1004 P2005 Male DrugE Headache Failure 33 226.00 33.00 2.00 31.00 0.00 86.00 232.00 1004 2005 1 5 4
21 T1005 P2001 Male DrugB Insomnia Success 62 170.00 54.00 -13.00 20.00 -7.00 61.00 158.00 1005 2001 1 2 6
22 T1005 P2002 Male DrugA None Success 50 201.00 94.00 9.00 13.00 6.00 72.00 163.00 1005 2002 1 1 1
23 T1005 P2003 Male DrugA Nausea Failure 21 200.00 42.00 -6.00 14.00 1.00 65.00 243.00 1005 2003 1 1 2
24 T1005 P2004 Male DrugA Headache Success 25 244.00 96.00 11.00 22.00 -5.00 92.00 216.00 1005 2004 1 1 4
25 T1005 P2005 Male DrugE None Failure 68 274.00 22.00 1.00 8.00 -4.00 88.00 222.00 1005 2005 1 5 1


/* Step 2: Descriptive Statistics */

PROC MEANS DATA=Clinical_Trials N MEAN STD MIN MAX;

    VAR Age Dosage_mg Efficacy BP_Change Recovery_Time Weight_Change Heart_Rate Cholesterol_Level;

RUN;


OUTPUT:

                                                           The MEANS Procedure

Variable N Mean Std Dev Minimum Maximum
Age
Dosage_mg
Efficacy
BP_Change
Recovery_Time
Weight_Change
Heart_Rate
Cholesterol_Level
25
25
25
25
25
25
25
25
48.4800000
183.4000000
53.1200000
1.4400000
17.6400000
0.4400000
77.6000000
195.4000000
17.7766701
63.1116735
31.9600271
9.4959641
8.8028405
5.2605450
11.8392004
30.8963320
21.0000000
74.0000000
0
-14.0000000
6.0000000
-8.0000000
61.0000000
154.0000000
78.0000000
292.0000000
98.0000000
15.0000000
32.0000000
9.0000000
96.0000000
243.0000000


/* Step 3: Additional Summary Statistics */

PROC MEANS DATA=Clinical_Trials N MEDIAN Q1 Q3;

    VAR Age Dosage_mg Efficacy BP_Change Recovery_Time;

RUN;


OUTPUT:

                                                          The MEANS Procedure

Variable N Median Lower Quartile Upper Quartile
Age
Dosage_mg
Efficacy
BP_Change
Recovery_Time
25
25
25
25
25
50.0000000
187.0000000
54.0000000
1.0000000
19.0000000
33.0000000
147.0000000
33.0000000
-6.0000000
9.0000000
64.0000000
232.0000000
83.0000000
11.0000000
25.0000000


/* Step 4: Frequency Analysis */

PROC FREQ DATA=Clinical_Trials;

    TABLES Gender Drug_Name Side_Effects Outcome / NOROW NOCOL NOPERCENT;

RUN;


OUTPUT:

                                                                    The FREQ Procedure

Gender Frequency Cumulative
Frequency
Female 10 10
Male 15 25


Drug_Name Frequency Cumulative
Frequency
DrugA 6 6
DrugB 4 10
DrugC 3 13
DrugD 4 17
DrugE 8 25


Side_Effects Frequency Cumulative
Frequency
Dizziness 5 5
Fatigue 2 7
Headache 8 15
Insomnia 3 18
Nausea 2 20
None 5 25


Outcome Frequency Cumulative
Frequency
Failure 11 11
Success 14 25


/* Step 5: Univariate Analysis with Outlier Detection */

PROC UNIVARIATE DATA=Clinical_Trials;

    VAR Age Dosage_mg Efficacy BP_Change Recovery_Time Weight_Change Heart_Rate Cholesterol_Level;

    HISTOGRAM / NORMAL;

    QQPLOT;

RUN;


OUTPUT:

                                                  The UNIVARIATE Procedure
                                                          Variable: Age

Moments
N 25 Sum Weights 25
Mean 48.48 Sum Observations 1212
Std Deviation 17.7766701 Variance 316.01
Skewness 0.11151479 Kurtosis -1.2704097
Uncorrected SS 66342 Corrected SS 7584.24
Coeff Variation 36.6680489 Std Error Mean 3.55533402


Basic Statistical Measures
Location Variability
Mean 48.48000 Std Deviation 17.77667
Median 50.00000 Variance 316.01000
Mode 33.00000 Range 57.00000
    Interquartile Range 31.00000

NOTE: ONLY AGE VARIABLE OUTPUT PLACED HERE TRY TO SEE ALL VARIABLES IN SAS...


/* Step 6: Correlation Analysis */

PROC CORR DATA=Clinical_Trials;

    VAR Age Dosage_mg Efficacy BP_Change Recovery_Time Heart_Rate Cholesterol_Level;

RUN;


OUTPUT:

Pearson Correlation Coefficients, N = 25
Prob > |r| under H0: Rho=0
  Age Dosage_mg Efficacy BP_Change Recovery_Time Heart_Rate Cholesterol_Level
Age
1.00000
 
-0.22513
0.2793
-0.38843
0.0550
-0.06326
0.7639
0.04588
0.8276
-0.06161
0.7699
-0.16127
0.4412
Dosage_mg
-0.22513
0.2793
1.00000
 
-0.03909
0.8528
-0.00323
0.9878
0.03312
0.8751
0.03931
0.8520
0.14770
0.4811
Efficacy
-0.38843
0.0550
-0.03909
0.8528
1.00000
 
0.03497
0.8682
0.17062
0.4148
0.17610
0.3998
0.17966
0.3901
BP_Change
-0.06326
0.7639
-0.00323
0.9878
0.03497
0.8682
1.00000
 
-0.17149
0.4124
0.10466
0.6186
-0.04848
0.8180
Recovery_Time
0.04588
0.8276
0.03312
0.8751
0.17062
0.4148
-0.17149
0.4124
1.00000
 
0.17887
0.3923
0.35291
0.0836
Heart_Rate
-0.06161
0.7699
0.03931
0.8520
0.17610
0.3998
0.10466
0.6186
0.17887
0.3923
1.00000
 
0.34002
0.0963
Cholesterol_Level
-0.16127
0.4412
0.14770
0.4811
0.17966
0.3901
-0.04848
0.8180
0.35291
0.0836
0.34002
0.0963
1.00000
 


/* Step 7: Report Generation */

PROC REPORT DATA=Clinical_Trials NOWD;

    COLUMN Trial_ID Patient_ID Gender Drug_Name Dosage_mg Efficacy Recovery_Time Outcome Heart_Rate Cholesterol_Level;

    DEFINE Trial_ID / GROUP;

    DEFINE Patient_ID / DISPLAY;

    DEFINE Gender / GROUP;

    DEFINE Drug_Name / GROUP;

    DEFINE Dosage_mg / ANALYSIS MEAN;

    DEFINE Efficacy / ANALYSIS MEAN;

    DEFINE Recovery_Time / ANALYSIS MEAN;

    DEFINE Outcome / GROUP;

    DEFINE Heart_Rate / ANALYSIS MEAN;

    DEFINE Cholesterol_Level / ANALYSIS MEAN;

RUN;


OUTPUT:

Trial_ID Patient_ID Gender Drug_Name Dosage_mg Efficacy Recovery_Time Outcome Heart_Rate Cholesterol_Level
T1001 P2005 Female DrugA 129.00 97.00 25.00 Success 88.00 210.00
  P2004   DrugD 187.00 98.00 20.00 Success 88.00 185.00
  P2003 Male DrugA 228.00 0.00 12.00 Failure 66.00 162.00
  P2001   DrugB 74.00 26.00 8.00 Failure 66.00 154.00
  P2002   DrugE 292.00 74.00 15.00 Success 71.00 185.00
T1002 P2002 Female DrugC 91.00 83.00 21.00 Success 96.00 177.00
  P2004   DrugE 153.00 1.00 7.00 Failure 95.00 167.00
  P2003 Male DrugB 124.00 37.00 8.00 Failure 62.00 155.00
  P2001     232.00 92.00 6.00 Success 74.00 186.00
  P2005   DrugE 77.00 75.00 27.00 Success 82.00 242.00
T1003 P2005 Female DrugC 163.00 8.00 20.00 Failure 90.00 239.00
  P2003   DrugE 162.00 48.00 29.00 Failure 63.00 216.00
  P2002 Male DrugA 240.00 61.00 10.00 Success 92.00 220.00
  P2004   DrugD 266.00 6.00 28.00 Failure 79.00 158.00
  P2001   DrugE 232.00 56.00 31.00 Success 76.00 195.00
T1004 P2003 Female DrugC 83.00 33.00 6.00 Failure 68.00 155.00
  P2001   DrugD 147.00 84.00 19.00 Success 87.00 228.00
  P2004     175.00 53.00 32.00   72.00 203.00
  P2002   DrugE 215.00 55.00 9.00 Success 61.00 214.00
  P2005 Male DrugE 226.00 33.00 31.00 Failure 86.00 232.00
T1005 P2003 Male DrugA 200.00 42.00 14.00 Failure 65.00 243.00
  P2002     201.00 94.00 13.00 Success 72.00 163.00
  P2004     244.00 96.00 22.00   92.00 216.00
  P2001   DrugB 170.00 54.00 20.00 Success 61.00 158.00
  P2005   DrugE 274.00 22.00 8.00 Failure 88.00 222.00


/* Step 8: Advanced SQL Queries */

PROC SQL;

    SELECT Drug_Name, AVG(Efficacy) AS Avg_Efficacy, COUNT(*) AS Total_Patients

    FROM Clinical_Trials

    GROUP BY Drug_Name

    ORDER BY Avg_Efficacy DESC;

QUIT;


OUTPUT:

Drug_Name Avg_Efficacy Total_Patients
DrugA 65 6
DrugD 60.25 4
DrugB 52.25 4
DrugE 45.5 8
DrugC 41.33333 3


PROC SQL;

    SELECT Gender, AVG(Age) AS Avg_Age, COUNT(*) AS Total_Patients

    FROM Clinical_Trials

    GROUP BY Gender;

QUIT;


OUTPUT:

Gender Avg_Age Total_Patients
Female 55 10
Male 44.13333 15


PROC SQL;

    SELECT Side_Effects, COUNT(*) AS Frequency

    FROM Clinical_Trials

    GROUP BY Side_Effects

    ORDER BY Frequency DESC;

QUIT;


OUTPUT:

Side_Effects Frequency
Headache 8
None 5
Dizziness 5
Insomnia 3
Fatigue 2
Nausea 2

PROC SQL;

    SELECT AVG(Heart_Rate) AS Avg_Heart_Rate, AVG(Cholesterol_Level) AS Avg_Cholesterol

    FROM Clinical_Trials;

QUIT;


OUTPUT:

Avg_Heart_Rate Avg_Cholesterol
77.6 195.4


/* Step 9: Data Visualization */

PROC SGPLOT DATA=Clinical_Trials;

    VBOX Efficacy / CATEGORY=Drug_Name;

    TITLE "Drug Efficacy Comparison";

RUN;


PROC SGPLOT DATA=Clinical_Trials;

    VBAR Side_Effects / RESPONSE=BP_Change GROUP=Drug_Name;

    TITLE "Side Effects vs BP Change";

RUN;


PROC SGPLOT DATA=Clinical_Trials;

    SCATTER X=Age Y=Efficacy / GROUP=Drug_Name;

    TITLE "Age vs Efficacy by Drug";

RUN;


PROC SGPLOT DATA=Clinical_Trials;

    HISTOGRAM Recovery_Time / NORMAL;

    TITLE "Recovery Time Distribution";

RUN;


PROC SGPLOT DATA=Clinical_Trials;

    SERIES X=Age Y=Heart_Rate / GROUP=Gender;

    TITLE "Heart Rate vs Age";

RUN;


PROC SGPLOT DATA=Clinical_Trials;

    VBOX Cholesterol_Level / CATEGORY=Gender;

    TITLE "Cholesterol Levels by Gender";

RUN;


/* Step 10: Data Export */

PROC EXPORT DATA=Clinical_Trials

    OUTFILE="clinical_trials_output.csv"

    DBMS=CSV

    REPLACE;

RUN;




PRACTICE AND COMMENT YOUR CODE: 

-->PLEASE FOLLOW OUR BLOG FOR MORE UPDATES.

TO FOLLOW OUR TELEGRAM CHANNEL CLICK HERE