Monday, 30 June 2025

226.GLOBAL EPILEPSY TREATMENT DATA ANALYSIS USING PROC OPTIONS | PROC FORMAT | PROC PRINT | PROC CONTENTS | PROC FREQ | PROC MEANS | PROC SGPLOT | PROC SQL | PROC EXPORT | PROC COMPARE

GLOBAL EPILEPSY TREATMENT DATA ANALYSIS USING PROC OPTIONS | PROC FORMAT | PROC PRINT | PROC CONTENTS | PROC FREQ | PROC MEANS | PROC SGPLOT | PROC SQL | PROC EXPORT | PROC COMPARE

 /*Worldwide epilepsy‑treatment dataset*/

1.Global program‑level OPTIONS (good style)

options nocenter nodate nonumber ls=132 ps=60

        varlenchk=NOWARN         /* ignore length “shrinking” */

        fmtsearch=(work);        /* look‑up custom formats    */


2.Creating the 25‑row dataset

data work.epil_world;

   length PatientID $8  Country $20 Region $15  EpilepsyType $25

          Sex $1 PrimaryDrug $15 SeizureControl $12 TreatmentRegimen $10 ;

   format DiagnosisDate TreatmentStart TreatmentEnd date9. ;


   infile datalines dsd truncover;

   input PatientID Country Region EpilepsyType $

         Age Sex $

         DiagnosisDate :date9.

         TreatmentStart :date9.

         TreatmentEnd   :date9.

         PrimaryDrug $ SeizureControl $ ;


   /*—— DERIVE LENGTH‑OF‑TREATMENT ——*/

   DurationMonths = intck('month', TreatmentStart, TreatmentEnd );


   /*—— DERIVE REGIMEN TYPE ——*/

   TreatmentRegimen = ifc(DurationMonths>24, 'Poly', 'Mono');


   label DurationMonths = 'Treatment Duration (Months)';

datalines;

P001,India,Asia,Focal,24,M,05JAN2022,15JAN2022,15JUL2024,Levetiracetam,Controlled

P002,USA,NorthAmerica,Generalized,32,F,20MAR2021,10APR2021,10JUN2023,Valproate,Partial

P003,Brazil,SouthAmerica,Focal_to_Bilateral,45,M,12DEC2019,01JAN2020,01JAN2024,Carbamazepine,Controlled

P004,UK,Europe,Generalized,29,F,15FEB2020,20FEB2020,20FEB2022,Topiramate,Controlled

P005,Japan,Asia,Focal,38,M,01AUG2018,15AUG2018,15FEB2025,Lacosamide,Uncontrolled

P006,Nigeria,Africa,Unknown,27,F,10OCT2022,20OCT2022,20APR2024,Phenytoin,Partial

P007,Germany,Europe,Focal,51,M,05MAY2017,20MAY2017,20MAY2020,Carbamazepine,Controlled

P008,Canada,NorthAmerica,Generalized,33,F,02JAN2023,05JAN2023,05JUL2024,Valproate,Partial

P009,Australia,Oceania,Focal,41,M,22JUL2020,01AUG2020,01FEB2023,Levetiracetam,Controlled

P010,India,Asia,Focal_to_Bilateral,16,F,12SEP2023,15SEP2023,15MAR2025,Oxcarbazepine,Uncontrolled

P011,France,Europe,Generalized,60,M,20APR2016,01MAY2016,01MAY2024,Valproate,Controlled

P012,Brazil,SouthAmerica,Focal,34,F,15NOV2020,20NOV2020,20NOV2023,Lacosamide,Partial

P013,USA,NorthAmerica,Unknown,22,M,01JAN2024,15JAN2024,15JUN2024,Levetiracetam,Uncontrolled

P014,Japan,Asia,Generalized,57,F,10JUN2019,20JUN2019,20DEC2023,Topiramate,Controlled

P015,India,Asia,Focal,30,M,05JUL2021,10JUL2021,10JAN2025,Carbamazepine,Partial

P016,Kenya,Africa,Focal,28,F,22FEB2022,01MAR2022,01MAR2024,Lacosamide,Controlled

P017,UK,Europe,Unknown,46,M,11NOV2020,20NOV2020,20NOV2023,Phenytoin,Partial

P018,USA,NorthAmerica,Focal_to_Bilateral,37,F,01APR2022,10APR2022,10OCT2024,Valproate,Controlled

P019,Australia,Oceania,Generalized,19,M,01JAN2023,05JAN2023,05JAN2025,Levetiracetam,Controlled

P020,India,Asia,Focal,52,F,15DEC2018,01JAN2019,01JAN2024,Carbamazepine,Uncontrolled

P021,Germany,Europe,Focal,48,M,20MAY2020,25MAY2020,25NOV2023,Lacosamide,Partial

P022,Canada,NorthAmerica,Generalized,31,F,02FEB2021,10FEB2021,10AUG2023,Topiramate,Controlled

P023,Nigeria,Africa,Focal_to_Bilateral,43,M,08AUG2019,15AUG2019,15FEB2023,Valproate,Partial

P024,Brazil,SouthAmerica,Generalized,26,F,10DEC2022,20DEC2022,20JUN2024,Phenytoin,Controlled

P025,Japan,Asia,Unknown,55,M,01SEP2020,10SEP2020,10MAR2023,Levetiracetam,Uncontrolled

;

run;

proc print;run;

Output:

Obs PatientID Country Region EpilepsyType Sex PrimaryDrug SeizureControl TreatmentRegimen DiagnosisDate TreatmentStart TreatmentEnd Age DurationMonths
1 P001 India Asia Focal M Levetiracetam Controlled Poly 05JAN2022 15JAN2022 15JUL2024 24 30
2 P002 USA NorthAmerica Generalized F Valproate Partial Poly 20MAR2021 10APR2021 10JUN2023 32 26
3 P003 Brazil SouthAmerica Focal_to_Bilateral M Carbamazepine Controlled Poly 12DEC2019 01JAN2020 01JAN2024 45 48
4 P004 UK Europe Generalized F Topiramate Controlled Mono 15FEB2020 20FEB2020 20FEB2022 29 24
5 P005 Japan Asia Focal M Lacosamide Uncontrolled Poly 01AUG2018 15AUG2018 15FEB2025 38 78
6 P006 Nigeria Africa Unknown F Phenytoin Partial Mono 10OCT2022 20OCT2022 20APR2024 27 18
7 P007 Germany Europe Focal M Carbamazepine Controlled Poly 05MAY2017 20MAY2017 20MAY2020 51 36
8 P008 Canada NorthAmerica Generalized F Valproate Partial Mono 02JAN2023 05JAN2023 05JUL2024 33 18
9 P009 Australia Oceania Focal M Levetiracetam Controlled Poly 22JUL2020 01AUG2020 01FEB2023 41 30
10 P010 India Asia Focal_to_Bilateral F Oxcarbazepine Uncontrolled Mono 12SEP2023 15SEP2023 15MAR2025 16 18
11 P011 France Europe Generalized M Valproate Controlled Poly 20APR2016 01MAY2016 01MAY2024 60 96
12 P012 Brazil SouthAmerica Focal F Lacosamide Partial Poly 15NOV2020 20NOV2020 20NOV2023 34 36
13 P013 USA NorthAmerica Unknown M Levetiracetam Uncontrolled Mono 01JAN2024 15JAN2024 15JUN2024 22 5
14 P014 Japan Asia Generalized F Topiramate Controlled Poly 10JUN2019 20JUN2019 20DEC2023 57 54
15 P015 India Asia Focal M Carbamazepine Partial Poly 05JUL2021 10JUL2021 10JAN2025 30 42
16 P016 Kenya Africa Focal F Lacosamide Controlled Mono 22FEB2022 01MAR2022 01MAR2024 28 24
17 P017 UK Europe Unknown M Phenytoin Partial Poly 11NOV2020 20NOV2020 20NOV2023 46 36
18 P018 USA NorthAmerica Focal_to_Bilateral F Valproate Controlled Poly 01APR2022 10APR2022 10OCT2024 37 30
19 P019 Australia Oceania Generalized M Levetiracetam Controlled Mono 01JAN2023 05JAN2023 05JAN2025 19 24
20 P020 India Asia Focal F Carbamazepine Uncontrolled Poly 15DEC2018 01JAN2019 01JAN2024 52 60
21 P021 Germany Europe Focal M Lacosamide Partial Poly 20MAY2020 25MAY2020 25NOV2023 48 42
22 P022 Canada NorthAmerica Generalized F Topiramate Controlled Poly 02FEB2021 10FEB2021 10AUG2023 31 30
23 P023 Nigeria Africa Focal_to_Bilateral M Valproate Partial Poly 08AUG2019 15AUG2019 15FEB2023 43 42
24 P024 Brazil SouthAmerica Generalized F Phenytoin Controlled Mono 10DEC2022 20DEC2022 20JUN2024 26 18
25 P025 Japan Asia Unknown M Levetiracetam Uncontrolled Poly 01SEP2020 10SEP2020 10MAR2023 55 30

3.First‑look exploration

3.1 What’s inside? (PROC CONTENTS)

proc contents data=work.epil_world varnum;

   title "Structure of EPIL_W (Worldwide Epilepsy Study)";

run;

Output:

Structure of EPIL_WORLD (Worldwide Epilepsy Study)

The CONTENTS Procedure

Data Set Name WORK.EPIL_WORLD Observations 25
Member Type DATA Variables 13
Engine V9 Indexes 0
Created 14/09/2015 00:06:14 Observation Length 152
Last Modified 14/09/2015 00:06:14 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label      
Data Representation WINDOWS_64    
Encoding wlatin1 Western (Windows)    


Engine/Host Dependent Information
Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 430
Obs in First Data Page 25
Number of Data Set Repairs 0
ExtendObsCounter YES
Filename C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD10416_DESKTOP-QFAA4KV_\epil_world.sas7bdat
Release Created 9.0401M2
Host Created X64_8HOME


Variables in Creation Order
# Variable Type Len Format Label
1 PatientID Char 8    
2 Country Char 20    
3 Region Char 15    
4 EpilepsyType Char 25    
5 Sex Char 1    
6 PrimaryDrug Char 15    
7 SeizureControl Char 12    
8 TreatmentRegimen Char 10    
9 DiagnosisDate Num 8 DATE9.  
10 TreatmentStart Num 8 DATE9.  
11 TreatmentEnd Num 8 DATE9.  
12 Age Num 8    
13 DurationMonths Num 8   Treatment Duration (Months)


3.2 Raw peek (PROC PRINT with WHERE)

proc print data=work.epil_world(obs=10);

   title "First 10 Records – Sanity Check";

   where Country in ('India','USA');

run;

Output:

First 10 Records – Sanity Check

Obs PatientID Country Region EpilepsyType Sex PrimaryDrug SeizureControl TreatmentRegimen DiagnosisDate TreatmentStart TreatmentEnd Age DurationMonths
1 P001 India Asia Focal M Levetiracetam Controlled Poly 05JAN2022 15JAN2022 15JUL2024 24 30
2 P002 USA NorthAmerica Generalized F Valproate Partial Poly 20MAR2021 10APR2021 10JUN2023 32 26
10 P010 India Asia Focal_to_Bilateral F Oxcarbazepine Uncontrolled Mono 12SEP2023 15SEP2023 15MAR2025 16 18
13 P013 USA NorthAmerica Unknown M Levetiracetam Uncontrolled Mono 01JAN2024 15JAN2024 15JUN2024 22 5
15 P015 India Asia Focal M Carbamazepine Partial Poly 05JUL2021 10JUL2021 10JAN2025 30 42
18 P018 USA NorthAmerica Focal_to_Bilateral F Valproate Controlled Poly 01APR2022 10APR2022 10OCT2024 37 30
20 P020 India Asia Focal F Carbamazepine Uncontrolled Poly 15DEC2018 01JAN2019 01JAN2024 52 60

4.Descriptive statistics

4.1 Demographics by epilepsy type (PROC FREQ)

proc freq data=work.epil_world order=freq;

   table EpilepsyType*Sex / nocol nopercent nocum;

   title "Sex Distribution by Epilepsy Classification";

run;

Output:

Sex Distribution by Epilepsy Classification

The FREQ Procedure

Frequency
Row Pct
Table of EpilepsyType by Sex
EpilepsyType Sex
M F Total
Focal
6
66.67
3
33.33
9
 
Generalized
2
25.00
6
75.00
8
 
Focal_to_Bilateral
2
50.00
2
50.00
4
 
Unknown
3
75.00
1
25.00
4
 
Total
13
12
25


4.2 Treatment length distribution (PROC MEANS)

proc means data=work.epil_world n mean median min max maxdec=1;

   class EpilepsyType;

   var DurationMonths Age;

   title "Duration & Age, Broken Down by Epilepsy Class";

run;

Output:

Duration & Age, Broken Down by Epilepsy Class

The MEANS Procedure

EpilepsyType N Obs Variable Label N Mean Median Minimum Maximum
Focal 9
DurationMonths
Age
Treatment Duration (Months)
 
9
9
42.0
38.4
36.0
38.0
24.0
24.0
78.0
52.0
Focal_to_Bilateral 4
DurationMonths
Age
Treatment Duration (Months)
 
4
4
34.5
35.3
36.0
40.0
18.0
16.0
48.0
45.0
Generalized 8
DurationMonths
Age
Treatment Duration (Months)
 
8
8
36.3
35.9
25.0
31.5
18.0
19.0
96.0
60.0
Unknown 4
DurationMonths
Age
Treatment Duration (Months)
 
4
4
22.3
37.5
24.0
36.5
5.0
22.0
36.0
55.0

4.3 Quick plot (PROC SGPLOT with summary function)

proc sgplot data=work.epil_world;

   vbox DurationMonths / category=Region;

   title "Boxplot: Months on Treatment by Global Region";

run;

Log:

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           3.32 seconds

      cpu time            0.56 seconds


NOTE: Listing image output written to SGPlot1.png.

NOTE: There were 25 observations read from the data set WORK.EPIL_WORLD.


5.Custom formats to declutter outputs

proc format;

   value $reg 'NorthAmerica' = 'N. America'

              'SouthAmerica' = 'S. America'

              'Oceania'      = 'Oce'

              other          = 'OTHER';

run;


proc freq data=work.epil_world;

   format Region $reg.;

   tables Region*SeizureControl / norow nocol nopercent;

   title "Outcome vs Region Using User Format";

run;

Output:

Outcome vs Region Using User Format

The FREQ Procedure

Frequency
Table of Region by SeizureControl
Region SeizureControl
Controlled Partial Uncontrolled Total
OTHER
6
5
4
15
N. America
2
2
1
5
Oce
2
0
0
2
S. America
2
1
0
3
Total
12
8
5
25

6.Analytic SQL snippets

proc sql;

   title "Mean Treatment Duration by Country & Control Status";

   select Country,

          SeizureControl,

          count(*)               as N_Patients,

          mean(DurationMonths)   as Avg_Months format=5.1

   from   work.epil_world

   group  by Country, SeizureControl

   having calculated Avg_Months > 18

   order  by Avg_Months desc;

quit;

Output:

Mean Treatment Duration by Country & Control Status

Country SeizureControl N_Patients Avg_Months
France Controlled 1 96.0
Japan Uncontrolled 2 54.0
Japan Controlled 1 54.0
Germany Partial 1 42.0
India Partial 1 42.0
India Uncontrolled 2 39.0
UK Partial 1 36.0
Germany Controlled 1 36.0
Brazil Partial 1 36.0
Brazil Controlled 2 33.0
Nigeria Partial 2 30.0
Canada Controlled 1 30.0
India Controlled 1 30.0
USA Controlled 1 30.0
Australia Controlled 2 27.0
USA Partial 1 26.0
UK Controlled 1 24.0
Kenya Controlled 1 24.0


7.Reusable macro: %SummaryBy

%macro SummaryBy(data=, class=, statvar=, outfile=);

   %local i n var;

   %let n=%sysfunc(countw(&class));


   %do i=1 %to &n;

      %let var=%scan(&class,&i);


      title "===&var Summary===";

      proc means data=&data n mean median maxdec=1;

         class &var;

         var &statvar;

      run;


      proc freq data=&data;

         tables &var / nocum nopercent;

      run;


      /*—— optional export ——*/

      %if %length(&outfile) %then %do;

         proc export data=&data(keep=&var &statvar)

             outfile="&outfile._&var..csv"

             dbms=csv replace;

         run;

      %end;

   %end;

%mend SummaryBy;


%SummaryBy(data=work.epil_world,

           class=Region EpilepsyType TreatmentRegimen,

           statvar=DurationMonths,

           outfile=%sysfunc(pathname(work))/epil_out);

Output:

===Region Summary===

The MEANS Procedure

Analysis Variable : DurationMonths Treatment Duration (Months)
Region N Obs N Mean Median
Africa 3 3 28.0 24.0
Asia 7 7 44.6 42.0
Europe 5 5 46.8 36.0
NorthAmerica 5 5 21.8 26.0
Oceania 2 2 27.0 27.0
SouthAmerica 3 3 34.0 36.0


===Region Summary===

The FREQ Procedure

Region Frequency
Africa 3
Asia 7
Europe 5
NorthAmerica 5
Oceania 2
SouthAmerica 3

===EpilepsyType Summary===

The MEANS Procedure

Analysis Variable : DurationMonths Treatment Duration (Months)
EpilepsyType N Obs N Mean Median
Focal 9 9 42.0 36.0
Focal_to_Bilateral 4 4 34.5 36.0
Generalized 8 8 36.3 25.0
Unknown 4 4 22.3 24.0

===EpilepsyType Summary===

The FREQ Procedure

EpilepsyType Frequency
Focal 9
Focal_to_Bilateral 4
Generalized 8
Unknown 4

===TreatmentRegimen Summary===

The MEANS Procedure

Analysis Variable : DurationMonths Treatment Duration (Months)
TreatmentRegimen N Obs N Mean Median
Mono 8 8 18.6 18.0
Poly 17 17 43.9 36.0

===TreatmentRegimen Summary===

The FREQ Procedure

TreatmentRegimen Frequency
Mono 8
Poly 17

8.Quality‑control snapshot

Compare derived vs re‑computed (PROC COMPARE)

data qc;

   set work.epil_world;

   RecalcMonths = intck('month', TreatmentStart, TreatmentEnd);

run;

proc print;run;

Obs PatientID Country Region EpilepsyType Sex PrimaryDrug SeizureControl TreatmentRegimen DiagnosisDate TreatmentStart TreatmentEnd Age DurationMonths RecalcMonths
1 P001 India Asia Focal M Levetiracetam Controlled Poly 05JAN2022 15JAN2022 15JUL2024 24 30 30
2 P002 USA NorthAmerica Generalized F Valproate Partial Poly 20MAR2021 10APR2021 10JUN2023 32 26 26
3 P003 Brazil SouthAmerica Focal_to_Bilateral M Carbamazepine Controlled Poly 12DEC2019 01JAN2020 01JAN2024 45 48 48
4 P004 UK Europe Generalized F Topiramate Controlled Mono 15FEB2020 20FEB2020 20FEB2022 29 24 24
5 P005 Japan Asia Focal M Lacosamide Uncontrolled Poly 01AUG2018 15AUG2018 15FEB2025 38 78 78
6 P006 Nigeria Africa Unknown F Phenytoin Partial Mono 10OCT2022 20OCT2022 20APR2024 27 18 18
7 P007 Germany Europe Focal M Carbamazepine Controlled Poly 05MAY2017 20MAY2017 20MAY2020 51 36 36
8 P008 Canada NorthAmerica Generalized F Valproate Partial Mono 02JAN2023 05JAN2023 05JUL2024 33 18 18
9 P009 Australia Oceania Focal M Levetiracetam Controlled Poly 22JUL2020 01AUG2020 01FEB2023 41 30 30
10 P010 India Asia Focal_to_Bilateral F Oxcarbazepine Uncontrolled Mono 12SEP2023 15SEP2023 15MAR2025 16 18 18
11 P011 France Europe Generalized M Valproate Controlled Poly 20APR2016 01MAY2016 01MAY2024 60 96 96
12 P012 Brazil SouthAmerica Focal F Lacosamide Partial Poly 15NOV2020 20NOV2020 20NOV2023 34 36 36
13 P013 USA NorthAmerica Unknown M Levetiracetam Uncontrolled Mono 01JAN2024 15JAN2024 15JUN2024 22 5 5
14 P014 Japan Asia Generalized F Topiramate Controlled Poly 10JUN2019 20JUN2019 20DEC2023 57 54 54
15 P015 India Asia Focal M Carbamazepine Partial Poly 05JUL2021 10JUL2021 10JAN2025 30 42 42
16 P016 Kenya Africa Focal F Lacosamide Controlled Mono 22FEB2022 01MAR2022 01MAR2024 28 24 24
17 P017 UK Europe Unknown M Phenytoin Partial Poly 11NOV2020 20NOV2020 20NOV2023 46 36 36
18 P018 USA NorthAmerica Focal_to_Bilateral F Valproate Controlled Poly 01APR2022 10APR2022 10OCT2024 37 30 30
19 P019 Australia Oceania Generalized M Levetiracetam Controlled Mono 01JAN2023 05JAN2023 05JAN2025 19 24 24
20 P020 India Asia Focal F Carbamazepine Uncontrolled Poly 15DEC2018 01JAN2019 01JAN2024 52 60 60
21 P021 Germany Europe Focal M Lacosamide Partial Poly 20MAY2020 25MAY2020 25NOV2023 48 42 42
22 P022 Canada NorthAmerica Generalized F Topiramate Controlled Poly 02FEB2021 10FEB2021 10AUG2023 31 30 30
23 P023 Nigeria Africa Focal_to_Bilateral M Valproate Partial Poly 08AUG2019 15AUG2019 15FEB2023 43 42 42
24 P024 Brazil SouthAmerica Generalized F Phenytoin Controlled Mono 10DEC2022 20DEC2022 20JUN2024 26 18 18
25 P025 Japan Asia Unknown M Levetiracetam Uncontrolled Poly 01SEP2020 10SEP2020 10MAR2023 55 30 30

proc compare base=qc(rename=(DurationMonths=Dur1))

             compare=qc(rename=(RecalcMonths=Dur2))

             criterion=0.0001 /* tolerance */

             out=diff(where=(difference ne 0));

   id PatientID;

   var Dur1;

   with Dur2;

   title "QC: Derived Duration vs Recalc";

run;

Output:

QC: Derived Duration vs Recalc

The COMPARE Procedure                                                                                                               
Comparison of WORK.QC with WORK.QC                                                                                                  
(Method=RELATIVE(2.22E-10), Criterion=0.0001)                                                                                       
                                                                                                                                    
Data Set Summary                                                                                                                    
                                                                                                                                    
Dataset           Created          Modified  NVar    NObs                                                                           
                                                                                                                                    
WORK.QC  14SEP15:00:35:14  14SEP15:00:35:14    14      25                                                                           
WORK.QC  14SEP15:00:35:14  14SEP15:00:35:14    14      25                                                                           
                                                                                                                                    
                                                                                                                                    
Variables Summary                                                                                                                   
                                                                                                                                    
Number of Variables in Common: 12.                                                                                                  
Number of Variables in WORK.QC but not in WORK.QC: 2.                                                                               
Number of Variables in WORK.QC but not in WORK.QC: 2.                                                                               
Number of ID Variables: 1.                                                                                                          
Number of VAR Statement Variables: 1.                                                                                               
Number of WITH Statement Variables: 1.

To Visit My Previous Sas Questions Datasets:Click Here
To Visit My Previous Home Energy Consumption Dataset:Click Here
To Visit My Previous Wildlife Migration Dataset:Click Here
To Visit My Previous Endangered Species Dataset:Click Here


-->PRACTICE AND COMMENT YOUR OUTPUT: 
--->PLEASE FOLLOW OUR BLOG FOR MORE UPDATES.

PLEASE FOLLOW OUR TELEGRAM CHANNEL CLICK HERE

PLEASE FOLLOW OUR FACEBOOK PAGE  CLICK HERE

PLEASE FOLLOW OUR INSTAGRAM PAGE CLICK HERE

Sunday, 29 June 2025

225.ANALYZING LEGENDARY INDIAN COURTROOM SCENES USING PROC DATASTEP | PROC CONTENTS | PROC MEANS | PROC UNIVARIATE | PROC FREQ | PROC SQL | PROC REPORT | PROC SUMMARY | PROC EXPORT IN SAS

ANALYZING LEGENDARY INDIAN COURTROOM SCENES USING PROC DATASTEP | PROC CONTENTS | PROC MEANS | PROC UNIVARIATE | PROC FREQ | PROC SQL | PROC REPORT | PROC SUMMARY | PROC EXPORT IN SAS

/*Dataset of “ultimate” courtroom sequences in Indian cinema.*/

1.Global SAS environment options

options nocenter             

        fmtsearch=(work)     

        pagesize=60 linesize=120;


2.Creating the data set (DATA step + functions)

data court_scenes_in_films;

   infile datalines dsd truncover;

   length filmname $40 lang $12 verdict $15 lead_lawyer director $30 famous_quote $120;

   input filmid filmname :$40. lang :$12. rel_year scene_min verdict :$15.

         lead_lawyer :$30. director :$30. drama_score famous_quote :$120. boxoffice_cr;


   /*--- DERIVE decade label with INTNX + PUT ---*/

   dec_start = intnx('year', mdy(1,1,rel_year), 0, 'B'); /* first day of rel_year */

   decade    = put(year(dec_start), 4.) || "s";          /* e.g. '1990s' */


   /*--- Standardise verdict text */

   length verdict_up $15;

   verdict_up = upcase(verdict);


   /*--- Flag for “acquittal” vs “conviction” using COMPRESS + COMPBL ---*/

   if compress(verdict_up) in ("NOTGUILTY","ACQUITTAL") then outcome=0;

   else outcome=1;


   /*--- Make a brief slug for URLs with CATX ---*/

   slug = lowcase(catx('-', compress(filmname, , 'kad'), rel_year));


   label scene_min   = "Minutes of Courtroom Action"

         drama_score = "Subjective Drama Intensity 0–100"

         dec_start   = "Calendar start of release year"

         outcome     = "1=Conviction 0=Acquittal";


   format dec_start date9. boxoffice_cr 8.1;

datalines;

101,"Pink","Hindi",2016,29.4,"Not Guilty","Amitabh Bachchan","Aniruddha Roy Chowdhury",95,"No means no!",108.7

102,"Damini","Hindi",1993,24.7,"Guilty","Sunny Deol","Rajkumar Santoshi",97,"Tareekh pe tareekh!",39.8

103,"Court","Marathi",2014,38.2,"Adjourned","Vivek Gomber","Chaitanya Tamhane",92,"Justice delayed is justice denied",1.8

104,"Vakeel Saab","Telugu",2021,25.5,"Not Guilty","Pawan Kalyan","Venu Sriram",88,"Naaku real stamina undhi!",137.3

105,"Shahid","Hindi",2013,17.0,"Guilty","Rajkummar Rao","Hansal Mehta",90,"Terror has no religion",5.6

106,"Meri Jung","Hindi",1985,30.2,"Guilty","Anil Kapoor","Subhash Ghai",93,"Kanoon andha nahi hai!",9.7

107,"Veer-Zaara","Hindi",2004,15.3,"Not Guilty","Rani Mukerji","Yash Chopra",80,"Love knows no borders",97.5

108,"Anniyan","Tamil",2005,20.8,"Guilty","Vikram","S. Shankar",89,"Rules are for everyone!",100.1

109,"Oh My Kadavule","Tamil",2020,10.5,"Adjourned","Ashok Selvan","Ashwath Marimuthu",70,"Fate is playful",52.4

110,"Nerkonda Paarvai","Tamil",2019,28.7,"Not Guilty","Ajith Kumar","H. Vinoth",91,"No means no—Tamil edition",180.7

111,"Rustom","Hindi",2016,23.0,"Not Guilty","Akshay Kumar","Tinu Suresh Desai",85,"I confess my love, not guilt",216.3

112,"Jolly LLB","Hindi",2013,19.4,"Guilty","Arshad Warsi","Subhash Kapoor",87,"Jolly never quits",32.3

113,"Jolly LLB 2","Hindi",2017,22.8,"Guilty","Akshay Kumar","Subhash Kapoor",86,"Truth will out",195.0

114,"OMG","Hindi",2012,14.6,"Guilty","Paresh Rawal","Umesh Shukla",78,"God is in the details",83.2

115,"Raazi","Hindi",2018,8.4,"Adjourned","Alia Bhatt","Meghna Gulzar",82,"Watan ke aage kuch nahi",197.4

116,"Section 375","Hindi",2019,27.3,"Guilty","Akshaye Khanna","Ajay Bahl",94,"Law is a tool!",20.4

117,"Chekka Chivantha Vaanam","Tamil",2018,6.2,"Adjourned","Arvind Swami","Mani Ratnam",76,"Family first?",92.1

118,"Talvar","Hindi",2015,12.7,"Guilty","Irrfan Khan","Meghna Gulzar",90,"Truth has many versions",30.0

119,"Visaranai","Tamil",2015,16.5,"Guilty","Dinesh","Vetrimaaran",96,"Systemic rot exposed",6.0

120,"Kaappaan","Tamil",2019,9.9,"Acquittal","Suriya","K. V. Anand",75,"Nation over self",150.6

121,"Drishyam 2","Malayalam",2021,18.2,"Acquittal","Mohanlal","Jeethu Joseph",88,"Family is everything",58.0

122,"Manichitrathazhu","Malayalam",1993,11.0,"Adjourned","Suresh Gopi","Fazil",84,"Split personalities at play",23.5

123,"Nyaay: The Justice","Hindi",2021,21.4,"Guilty","Zuber K. Khan","Dilip Gulati",50,"Justice or vendetta?",0.9

124,"Thalaivi","Tamil",2021,13.6,"Acquittal","Kangana Ranaut","A. L. Vijay",79,"History will remember",30.7

125,"Singham","Hindi",2011,7.3,"Guilty","Ajay Devgn","Rohit Shetty",74,"Aata majhi satakli!",155.0

;

run;

proc print;run;

Output:

Obs filmname lang verdict lead_lawyer director famous_quote filmid rel_year scene_min drama_score boxoffice_cr dec_start decade verdict_up outcome slug
1 Pink Hindi Not Guilty Amitabh Bachchan Aniruddha Roy Chowdhury No means no! 101 2016 29.4 95 108.7 01JAN2016 2016s NOT GUILTY 0 pink-2016
2 Damini Hindi Guilty Sunny Deol Rajkumar Santoshi Tareekh pe tareekh! 102 1993 24.7 97 39.8 01JAN1993 1993s GUILTY 1 damini-1993
3 Court Marathi Adjourned Vivek Gomber Chaitanya Tamhane Justice delayed is justice denied 103 2014 38.2 92 1.8 01JAN2014 2014s ADJOURNED 1 court-2014
4 Vakeel Saab Telugu Not Guilty Pawan Kalyan Venu Sriram Naaku real stamina undhi! 104 2021 25.5 88 137.3 01JAN2021 2021s NOT GUILTY 0 vakeelsaab-2021
5 Shahid Hindi Guilty Rajkummar Rao Hansal Mehta Terror has no religion 105 2013 17.0 90 5.6 01JAN2013 2013s GUILTY 1 shahid-2013
6 Meri Jung Hindi Guilty Anil Kapoor Subhash Ghai Kanoon andha nahi hai! 106 1985 30.2 93 9.7 01JAN1985 1985s GUILTY 1 merijung-1985
7 Veer-Zaara Hindi Not Guilty Rani Mukerji Yash Chopra Love knows no borders 107 2004 15.3 80 97.5 01JAN2004 2004s NOT GUILTY 0 veerzaara-2004
8 Anniyan Tamil Guilty Vikram S. Shankar Rules are for everyone! 108 2005 20.8 89 100.1 01JAN2005 2005s GUILTY 1 anniyan-2005
9 Oh My Kadavule Tamil Adjourned Ashok Selvan Ashwath Marimuthu Fate is playful 109 2020 10.5 70 52.4 01JAN2020 2020s ADJOURNED 1 ohmykadavule-2020
10 Nerkonda Paarvai Tamil Not Guilty Ajith Kumar H. Vinoth No means no—Tamil edition 110 2019 28.7 91 180.7 01JAN2019 2019s NOT GUILTY 0 nerkondapaarvai-2019
11 Rustom Hindi Not Guilty Akshay Kumar Tinu Suresh Desai I confess my love, not guilt 111 2016 23.0 85 216.3 01JAN2016 2016s NOT GUILTY 0 rustom-2016
12 Jolly LLB Hindi Guilty Arshad Warsi Subhash Kapoor Jolly never quits 112 2013 19.4 87 32.3 01JAN2013 2013s GUILTY 1 jollyllb-2013
13 Jolly LLB 2 Hindi Guilty Akshay Kumar Subhash Kapoor Truth will out 113 2017 22.8 86 195.0 01JAN2017 2017s GUILTY 1 jollyllb2-2017
14 OMG Hindi Guilty Paresh Rawal Umesh Shukla God is in the details 114 2012 14.6 78 83.2 01JAN2012 2012s GUILTY 1 omg-2012
15 Raazi Hindi Adjourned Alia Bhatt Meghna Gulzar Watan ke aage kuch nahi 115 2018 8.4 82 197.4 01JAN2018 2018s ADJOURNED 1 raazi-2018
16 Section 375 Hindi Guilty Akshaye Khanna Ajay Bahl Law is a tool! 116 2019 27.3 94 20.4 01JAN2019 2019s GUILTY 1 section375-2019
17 Chekka Chivantha Vaanam Tamil Adjourned Arvind Swami Mani Ratnam Family first? 117 2018 6.2 76 92.1 01JAN2018 2018s ADJOURNED 1 chekkachivanthavaanam-2018
18 Talvar Hindi Guilty Irrfan Khan Meghna Gulzar Truth has many versions 118 2015 12.7 90 30.0 01JAN2015 2015s GUILTY 1 talvar-2015
19 Visaranai Tamil Guilty Dinesh Vetrimaaran Systemic rot exposed 119 2015 16.5 96 6.0 01JAN2015 2015s GUILTY 1 visaranai-2015
20 Kaappaan Tamil Acquittal Suriya K. V. Anand Nation over self 120 2019 9.9 75 150.6 01JAN2019 2019s ACQUITTAL 0 kaappaan-2019
21 Drishyam 2 Malayalam Acquittal Mohanlal Jeethu Joseph Family is everything 121 2021 18.2 88 58.0 01JAN2021 2021s ACQUITTAL 0 drishyam2-2021
22 Manichitrathazhu Malayalam Adjourned Suresh Gopi Fazil Split personalities at play 122 1993 11.0 84 23.5 01JAN1993 1993s ADJOURNED 1 manichitrathazhu-1993
23 Nyaay: The Justice Hindi Guilty Zuber K. Khan Dilip Gulati Justice or vendetta? 123 2021 21.4 50 0.9 01JAN2021 2021s GUILTY 1 nyaaythejustice-2021
24 Thalaivi Tamil Acquittal Kangana Ranaut A. L. Vijay History will remember 124 2021 13.6 79 30.7 01JAN2021 2021s ACQUITTAL 0 thalaivi-2021
25 Singham Hindi Guilty Ajay Devgn Rohit Shetty Aata majhi satakli! 125 2011 7.3 74 155.0 01JAN2011 2011s GUILTY 1 singham-2011

3.Quick structural check – PROC CONTENTS

proc contents data=court_scenes_in_films position;

   title "Structure of Court Scene Dataset";

run;

Output:

Structure of Court Scene Dataset

The CONTENTS Procedure

Data Set Name WORK.COURT_SCENES_IN_FILMS Observations 25
Member Type DATA Variables 16
Engine V9 Indexes 0
Created 14/09/2015 00:20:40 Observation Length 528
Last Modified 14/09/2015 00:20:40 Deleted Observations 0
Protection   Compressed NO
Data Set Type   Sorted NO
Label      
Data Representation WINDOWS_64    
Encoding wlatin1 Western (Windows)    

Engine/Host Dependent Information
Data Set Page Size 65536
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 124
Obs in First Data Page 25
Number of Data Set Repairs 0
ExtendObsCounter YES
Filename C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD13972_DESKTOP-QFAA4KV_\court_scenes_in_films.sas7bdat
Release Created 9.0401M2
Host Created X64_8HOME

Alphabetic List of Variables and Attributes
# Variable Type Len Format Label
11 boxoffice_cr Num 8 8.1  
12 dec_start Num 8 DATE9. Calendar start of release year
13 decade Char 5    
5 director Char 30    
10 drama_score Num 8   Subjective Drama Intensity 0–100
6 famous_quote Char 120    
7 filmid Num 8    
1 filmname Char 40    
2 lang Char 12    
4 lead_lawyer Char 30    
15 outcome Num 8   1=Conviction 0=Acquittal
8 rel_year Num 8    
9 scene_min Num 8   Minutes of Courtroom Action
16 slug Char 200    
3 verdict Char 15    
14 verdict_up Char 15    

Variables in Creation Order
# Variable Type Len Format Label
1 filmname Char 40    
2 lang Char 12    
3 verdict Char 15    
4 lead_lawyer Char 30    
5 director Char 30    
6 famous_quote Char 120    
7 filmid Num 8    
8 rel_year Num 8    
9 scene_min Num 8   Minutes of Courtroom Action
10 drama_score Num 8   Subjective Drama Intensity 0–100
11 boxoffice_cr Num 8 8.1  
12 dec_start Num 8 DATE9. Calendar start of release year
13 decade Char 5    
14 verdict_up Char 15    
15 outcome Num 8   1=Conviction 0=Acquittal
16 slug Char 200    

4.Descriptive stats – PROC MEANS |PROC UNIVARIATE |PROC FREQ

proc means data=court_scenes_in_films n min q1 median mean q3 max maxdec=1;

   var scene_min drama_score boxoffice_cr;

   class decade;

   title "Minutes, Drama Scores, and Box Office by Decade";

run;

Output:

Minutes, Drama Scores, and Box Office by Decade

The MEANS Procedure

decade N Obs Variable Label N Minimum Lower Quartile Median Mean Upper Quartile Maximum
1985s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
30.2
93.0
9.7
30.2
93.0
9.7
30.2
93.0
9.7
30.2
93.0
9.7
30.2
93.0
9.7
30.2
93.0
9.7
1993s 2
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
2
2
2
11.0
84.0
23.5
11.0
84.0
23.5
17.9
90.5
31.7
17.9
90.5
31.7
24.7
97.0
39.8
24.7
97.0
39.8
2004s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
15.3
80.0
97.5
15.3
80.0
97.5
15.3
80.0
97.5
15.3
80.0
97.5
15.3
80.0
97.5
15.3
80.0
97.5
2005s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
20.8
89.0
100.1
20.8
89.0
100.1
20.8
89.0
100.1
20.8
89.0
100.1
20.8
89.0
100.1
20.8
89.0
100.1
2011s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
7.3
74.0
155.0
7.3
74.0
155.0
7.3
74.0
155.0
7.3
74.0
155.0
7.3
74.0
155.0
7.3
74.0
155.0
2012s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
14.6
78.0
83.2
14.6
78.0
83.2
14.6
78.0
83.2
14.6
78.0
83.2
14.6
78.0
83.2
14.6
78.0
83.2
2013s 2
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
2
2
2
17.0
87.0
5.6
17.0
87.0
5.6
18.2
88.5
19.0
18.2
88.5
19.0
19.4
90.0
32.3
19.4
90.0
32.3
2014s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
38.2
92.0
1.8
38.2
92.0
1.8
38.2
92.0
1.8
38.2
92.0
1.8
38.2
92.0
1.8
38.2
92.0
1.8
2015s 2
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
2
2
2
12.7
90.0
6.0
12.7
90.0
6.0
14.6
93.0
18.0
14.6
93.0
18.0
16.5
96.0
30.0
16.5
96.0
30.0
2016s 2
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
2
2
2
23.0
85.0
108.7
23.0
85.0
108.7
26.2
90.0
162.5
26.2
90.0
162.5
29.4
95.0
216.3
29.4
95.0
216.3
2017s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
22.8
86.0
195.0
22.8
86.0
195.0
22.8
86.0
195.0
22.8
86.0
195.0
22.8
86.0
195.0
22.8
86.0
195.0
2018s 2
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
2
2
2
6.2
76.0
92.1
6.2
76.0
92.1
7.3
79.0
144.8
7.3
79.0
144.8
8.4
82.0
197.4
8.4
82.0
197.4
2019s 3
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
3
3
3
9.9
75.0
20.4
9.9
75.0
20.4
27.3
91.0
150.6
22.0
86.7
117.2
28.7
94.0
180.7
28.7
94.0
180.7
2020s 1
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
1
1
1
10.5
70.0
52.4
10.5
70.0
52.4
10.5
70.0
52.4
10.5
70.0
52.4
10.5
70.0
52.4
10.5
70.0
52.4
2021s 4
scene_min
drama_score
boxoffice_cr
Minutes of Courtroom Action
Subjective Drama Intensity 0–100
 
4
4
4
13.6
50.0
0.9
15.9
64.5
15.8
19.8
83.5
44.4
19.7
76.3
56.7
23.5
88.0
97.7
25.5
88.0
137.3

proc univariate data=court_scenes_in_films noprint;

   var drama_score;

   histogram / midpoints=60 to 100 by 5;

   inset mean std / position=ne;

   title1 "Distribution of Drama Intensity Scores";

run;

Output:

WARNING: The MIDPOINTS= list was extended to accommodate the data.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           3.40 seconds
      cpu time            0.67 seconds

proc freq data=court_scenes_in_films order=freq;

   tables verdict_up*lang / chisq norow nocol nopercent;

   title1 "Verdict by Language (Chi‑square)";

run;

Output:

Verdict by Language (Chi-square)

The FREQ Procedure

Frequency
Table of verdict_up by lang
verdict_up lang
Hindi Tamil Malayalam Marathi Telugu Total
GUILTY
10
2
0
0
0
12
ADJOURNED
1
2
1
1
0
5
NOT GUILTY
3
1
0
0
1
5
ACQUITTAL
0
2
1
0
0
3
Total
14
7
2
1
1
25


Statistics for Table of verdict_up by lang

Statistic DF Value Prob
Chi-Square 12 19.6429 0.0742
Likelihood Ratio Chi-Square 12 19.5778 0.0755
Mantel-Haenszel Chi-Square 1 4.2098 0.0402
Phi Coefficient   0.8864  
Contingency Coefficient   0.6633  
Cramer's V   0.5118  
WARNING: 95% of the cells have expected counts less
than 5. Chi-Square may not be a valid test.


Sample Size = 25

5.PROC SQL: Top‑N queries and derived views

proc sql feedback outobs=5;

   /* Top 5 longest courtroom segments */

   create table top5_length as

   select filmname, scene_min format=8.2, rel_year

   from   court_scenes_in_films

   order  by scene_min desc;

quit;

proc print;run;

Output:

Obs filmname scene_min rel_year
1 Court 38.20 2014
2 Meri Jung 30.20 1985
3 Pink 29.40 2016
4 Nerkonda Paarvai 28.70 2019
5 Section 375 27.30 2019

proc sql; 

/* Average drama score by verdict */

   select verdict_up,

          mean(drama_score) as avg_drama label="Avg Drama Score" format=8.1

   from   court_scenes_in_films

   group  by verdict_up

   order  by avg_drama desc;

quit;

Output:

verdict_up Avg Drama Score
NOT GUILTY 87.8
GUILTY 85.3
ADJOURNED 80.8
ACQUITTAL 80.7

6.Reusable Macro – Summarise by any grouping

%macro court_summary(group=);

   %let grp = %upcase(&group);       


   %put NOTE: Running COURT_SUMMARY grouped by &grp;


   proc means data=court_scenes_in_films n mean median min max maxdec=1;

      class &group;

      var scene_min drama_score boxoffice_cr;

      title2 "Numeric Summary by &grp";

   run;


   proc freq data=court_scenes_in_films;

      tables &group * verdict_up / nopercent norow nocol;

      title2 "Verdict Crosstab by &grp";

   run;

%mend;


%court_summary(group=lang)

Output:

Verdict Crosstab by LANG

The FREQ Procedure

Frequency
Table of lang by verdict_up
lang verdict_up
ACQUITTAL ADJOURNED GUILTY NOT GUILTY Total
Hindi
0
1
10
3
14
Malayalam
1
1
0
0
2
Marathi
0
1
0
0
1
Tamil
2
2
2
1
7
Telugu
0
0
0
1
1
Total
3
5
12
5
25

%court_summary(group=director)

Output:

Verdict Crosstab by DIRECTOR

The FREQ Procedure

Frequency
Table of director by verdict_up
director verdict_up
ACQUITTAL ADJOURNED GUILTY NOT GUILTY Total
A. L. Vijay
1
0
0
0
1
Ajay Bahl
0
0
1
0
1
Aniruddha Roy Chowdhury
0
0
0
1
1
Ashwath Marimuthu
0
1
0
0
1
Chaitanya Tamhane
0
1
0
0
1
Dilip Gulati
0
0
1
0
1
Fazil
0
1
0
0
1
H. Vinoth
0
0
0
1
1
Hansal Mehta
0
0
1
0
1
Jeethu Joseph
1
0
0
0
1
K. V. Anand
1
0
0
0
1
Mani Ratnam
0
1
0
0
1
Meghna Gulzar
0
1
1
0
2
Rajkumar Santoshi
0
0
1
0
1
Rohit Shetty
0
0
1
0
1
S. Shankar
0
0
1
0
1
Subhash Ghai
0
0
1
0
1
Subhash Kapoor
0
0
2
0
2
Tinu Suresh Desai
0
0
0
1
1
Umesh Shukla
0
0
1
0
1
Venu Sriram
0
0
0
1
1
Vetrimaaran
0
0
1
0
1
Yash Chopra
0
0
0
1
1
Total
3
5
12
5
25

7.PROC REPORT for publication‑ready table

proc summary data=court_scenes_in_films nway;

   class decade verdict_up;

   var scene_min drama_score;

   output out=summary_out(drop=_type_ rename=(_freq_=cnt))

      mean(scene_min)=mean_scene

      mean(drama_score)=mean_drama;

run;


proc report data=summary_out nowd;

   column decade verdict_up cnt mean_scene mean_drama;


   define decade / group;

   define verdict_up / group;

   define cnt / 'Count';

   define mean_scene / 'Avg Minutes';

   define mean_drama / 'Avg Drama';


   compute after;

      line @1 "Summary created on %sysfunc(date(), worddate.)";

   endcomp;


   title "Pre-Summarized Courtroom Report";

run;

Output:

Pre-Summarized Courtroom Report

decade verdict_up Count Avg Minutes Avg Drama
1985s GUILTY 1 30.2 93
1993s ADJOURNED 1 11 84
  GUILTY 1 24.7 97
2004s NOT GUILTY 1 15.3 80
2005s GUILTY 1 20.8 89
2011s GUILTY 1 7.3 74
2012s GUILTY 1 14.6 78
2013s GUILTY 2 18.2 88.5
2014s ADJOURNED 1 38.2 92
2015s GUILTY 2 14.6 93
2016s NOT GUILTY 2 26.2 90
2017s GUILTY 1 22.8 86
2018s ADJOURNED 2 7.3 79
2019s ACQUITTAL 1 9.9 75
  GUILTY 1 27.3 94
  NOT GUILTY 1 28.7 91
2020s ADJOURNED 1 10.5 70
2021s ACQUITTAL 2 15.9 83.5
  GUILTY 1 21.4 50
  NOT GUILTY 1 25.5 88
Summary created on September 14, 2015

8.PROC TABULATE for multidimensional stats

proc tabulate data=court_scenes_in_films;

   class lang verdict_up;

   var drama_score boxoffice_cr;

   table lang,

         verdict_up*(drama_score*mean boxoffice_cr*mean);

   title "Mean Drama & Box‑Office by Language x Verdict Matrix";

run;

Output:

Mean Drama & Box-Office by Language x Verdict Matrix

  verdict_up
ACQUITTAL ADJOURNED GUILTY NOT GUILTY
Subjective Drama
Intensity 0–100
boxoffice_cr Subjective Drama
Intensity 0–100
boxoffice_cr Subjective Drama
Intensity 0–100
boxoffice_cr Subjective Drama
Intensity 0–100
boxoffice_cr
Mean Mean Mean Mean Mean Mean Mean Mean
lang . . 82.00 197.40 83.90 57.19 86.67 140.83
Hindi
Malayalam 88.00 58.00 84.00 23.50 . . . .
Marathi . . 92.00 1.80 . . . .
Tamil 77.00 90.65 73.00 72.25 92.50 53.05 91.00 180.70
Telugu . . . . . . 88.00 137.30

9.Exporting to CSV – PROC EXPORT

proc export data=court_scenes_in_films

            outfile="court_scenes.csv"

            dbms=csv replace;

   putnames=yes;

run;

Log:

NOTE: The file 'court_scenes.csv' is:
      Filename=C:\sas folder\SASFoundation\9.4\court_scenes.csv,
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=29 June 2025 17:32:11,
      Create Time=29 June 2025 17:32:11

NOTE: 26 records were written to the file 'court_scenes.csv'.
      The minimum record length was 120.
      The maximum record length was 154.
NOTE: There were 25 observations read from the data set WORK.COURT_SCENES_IN_FILMS.
NOTE: DATA statement used (Total process time):
      real time           0.28 seconds
      cpu time            0.06 seconds


25 records created in court_scenes.csv from COURT_SCENES_IN_FILMS.


NOTE: "court_scenes.csv" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           2.90 seconds
      cpu time            0.40 seconds



To Visit My Previous Sas Project 11-20 Questions:Click Here
To Visit My Previous %Let %Put %Eval In Sas:Click Here
To Visit My Previous Creating Assessing Cleaning Manipulation In Sas:Click Here
To Visit My Previous Proc Contents In Sas: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