229.HOLLYWOOD MUSIC DIRECTORS ANALYSIS USING PROC FORMAT | PROC PRINT | PROC CONTENTS | PROC SORT | PROC FREQ | PROC MEANS | PROC SQL | PROC REPORT | PROC SGPLOT IN SAS

HOLLYWOOD MUSIC DIRECTORS ANALYSIS USING PROC FORMAT | PROC PRINT | PROC CONTENTS | PROC SORT | PROC FREQ | PROC MEANS | PROC SQL | PROC REPORT | PROC SGPLOT IN SAS

/*Creating a dataset Hollywood  Music  Directors */

1 . Session‑wide OPTIONS

options nocenter             /* left‑aligned output for blog screenshots  */

        nodate               /* remove date stamp from results window     */

        fullstimer           /* CPU/real‑time stats for performance geeks */

        yearcutoff=1920      /* allow birth or debut years <1920 */

        errors=3             /* stop after 3 data errors   */

        dkricond=error       /* force SQL UPDATE or MODIFY integrity */

        validvarname=upcase; /* ensure column names are analytic‑ready    */


2 .Custom FORMAT Table

proc format;

   value oscfmt

      0        = 'NONE'

      1        = '1 WIN'

      2 - 3    = 'MULTI‑WINNER'

      4 - high = 'LEGEND';

run;


3 .DATA Step – Building the Core Dataset

data work.musicdirs;

   length DirID 8 Name $40 Country $20 PrimaryGenre $15 OscarWins 8 NotableWork $60

          DebutYear 8 ActiveYrs 8 AvgIMDb 4.1 TwitterM 8;


   infile datalines4 dlm='|' dsd;

   input DirID Name Country PrimaryGenre OscarWins NotableWork :$60. DebutYear ActiveYrs

         AvgIMDb TwitterM;


   /* Derived columns */

   CareerStage = catt(put(intck('YEAR', mdy(1,1,DebutYear), today()), 2.), ' Yrs');

   Name_UP     = upcase(Name);

   EraGroup    = cats(floor(DebutYear/10)*10, 's');

   WinLabel    = put(OscarWins, oscfmt.);

   USUBJID     = cats('MD-', put(DirID, z3.));


   label  CareerStage = "Total Career Length (yrs)"

          Name_UP     = "Upper-Case Name"

          EraGroup    = "Decade of Debut"

          WinLabel    = "Oscar Prestige Bucket";

datalines4;

001|Hans Zimmer|Germany|Epic|2|Inception|1984|40|8.9|1.3

002|John Williams|USA|Orchestral|5|Star Wars|1958|66|8.8|0.4

003|A.R. Rahman|India|World Fusion|2|Slumdog Millionaire|1992|33|8.1|27

004|Alan Menken|USA|Disney Musicals|2|The Little Mermaid|1979|45|8.0|0.15

005|Danny Elfman|USA|Gothic Pop|0|Batman|1980|44|7.7|0.6

006|Ennio Morricone|Italy|Spaghetti Western|1|The Good, the Bad…|1961|59|8.5|0.02

007|Howard Shore|Canada|Symphonic|3|The Lord of the Rings|1979|45|8.9|0.12

008|Thomas Newman|USA|Ambient|0|American Beauty|1984|40|8.3|0.08

009|Michael Giacchino|USA|Eclectic|1|Up|1994|31|8.4|0.5

010|James Horner|USA|Romantic|2|Titanic|1979|37|8.9|0.07

011|Alexandre Desplat|France|Lyric Modern|2|The Shape of Water|1986|39|8.1|0.09

012|Hildur Guðnadóttir|Iceland|Atmospheric|1|Joker|2006|19|8.2|0.4

013|Lorne Balfe|Scotland|Hybrid|0|Mission Impossible: Fallout|2002|23|7.6|0.23

014|Pinar Toprak|Turkey|Action-SciFi|0|Captain Marvel|2004|21|7.2|0.17

015|Justin Hurwitz|USA|Jazz-Infused|2|La La Land|2009|16|8.3|0.25

016|Ramin Djawadi|Germany|Epic TV|0|Game of Thrones|2004|21|9.3|0.85

017|Nicholas Britell|USA|Neo-Classical|0|Succession|2012|13|8.8|0.18

018|Rachel Portman|UK|Rom-Drama|1|Emma|1986|39|7.9|0.05

019|Gustavo Santaolalla|Argentina|Latin Fusion|2|Brokeback Mountain|1978|47|7.8|0.1

020|Mark Mothersbaugh|USA|Alt-Rock|0|The Royal Tenenbaums|1981|44|7.5|0.22

;;;;

run;

proc print;run;

Ouput:

Obs DIRID NAME COUNTRY PRIMARYGENRE OSCARWINS NOTABLEWORK DEBUTYEAR ACTIVEYRS AVGIMDB TWITTERM CAREERSTAGE NAME_UP ERAGROUP WINLABEL USUBJID
1 1 Hans Zimmer Germany Epic 2 Inception 1984 40 8.89999 1.30 31 Yrs HANS ZIMMER 1980s MULTI-WINNER MD-001
2 2 John Williams USA Orchestral 5 Star Wars 1958 66 8.80000 0.40 57 Yrs JOHN WILLIAMS 1950s LEGEND MD-002
3 3 A.R. Rahman India World Fusion 2 Slumdog Millionaire 1992 33 8.10000 27.00 23 Yrs A.R. RAHMAN 1990s MULTI-WINNER MD-003
4 4 Alan Menken USA Disney Musicals 2 The Little Mermaid 1979 45 8.00000 0.15 36 Yrs ALAN MENKEN 1970s MULTI-WINNER MD-004
5 5 Danny Elfman USA Gothic Pop 0 Batman 1980 44 7.70000 0.60 35 Yrs DANNY ELFMAN 1980s NONE MD-005
6 6 Ennio Morricone Italy Spaghetti Weste 1 The Good, the Bad… 1961 59 8.50000 0.02 54 Yrs ENNIO MORRICONE 1960s 1 WIN MD-006
7 7 Howard Shore Canada Symphonic 3 The Lord of the Rings 1979 45 8.89999 0.12 36 Yrs HOWARD SHORE 1970s MULTI-WINNER MD-007
8 8 Thomas Newman USA Ambient 0 American Beauty 1984 40 8.30000 0.08 31 Yrs THOMAS NEWMAN 1980s NONE MD-008
9 9 Michael Giacchino USA Eclectic 1 Up 1994 31 8.39999 0.50 21 Yrs MICHAEL GIACCHINO 1990s 1 WIN MD-009
10 10 James Horner USA Romantic 2 Titanic 1979 37 8.89999 0.07 36 Yrs JAMES HORNER 1970s MULTI-WINNER MD-010
11 11 Alexandre Desplat France Lyric Modern 2 The Shape of Water 1986 39 8.10000 0.09 29 Yrs ALEXANDRE DESPLAT 1980s MULTI-WINNER MD-011
12 12 Hildur Guðnadóttir Iceland Atmospheric 1 Joker 2006 19 8.20000 0.40 9 Yrs HILDUR GUÐNADÓTTIR 2000s 1 WIN MD-012
13 13 Lorne Balfe Scotland Hybrid 0 Mission Impossible: Fallout 2002 23 7.60000 0.23 13 Yrs LORNE BALFE 2000s NONE MD-013
14 14 Pinar Toprak Turkey Action-SciFi 0 Captain Marvel 2004 21 7.20000 0.17 11 Yrs PINAR TOPRAK 2000s NONE MD-014
15 15 Justin Hurwitz USA Jazz-Infused 2 La La Land 2009 16 8.30000 0.25 6 Yrs JUSTIN HURWITZ 2000s MULTI-WINNER MD-015
16 16 Ramin Djawadi Germany Epic TV 0 Game of Thrones 2004 21 9.30000 0.85 11 Yrs RAMIN DJAWADI 2000s NONE MD-016
17 17 Nicholas Britell USA Neo-Classical 0 Succession 2012 13 8.80000 0.18 3 Yrs NICHOLAS BRITELL 2010s NONE MD-017
18 18 Rachel Portman UK Rom-Drama 1 Emma 1986 39 7.90000 0.05 29 Yrs RACHEL PORTMAN 1980s 1 WIN MD-018
19 19 Gustavo Santaolalla Argentina Latin Fusion 2 Brokeback Mountain 1978 47 7.80000 0.10 37 Yrs GUSTAVO SANTAOLALLA 1970s MULTI-WINNER MD-019
20 20 Mark Mothersbaugh USA Alt-Rock 0 The Royal Tenenbaums 1981 44 7.50000 0.22 34 Yrs MARK MOTHERSBAUGH 1980s NONE MD-020


4 .First Peek – PROC PRINT & PROC CONTENTS

title "Snapshot of the First 10 Hollywood Music Directors";

proc print data=work.musicdirs(obs=10) label;

   format OscarWins oscfmt.;

run;

Ouput:

Snapshot of the First 10 Hollywood Music Directors

Obs DIRID NAME COUNTRY PRIMARYGENRE OSCARWINS NOTABLEWORK DEBUTYEAR ACTIVEYRS AVGIMDB TWITTERM Total Career
Length (yrs)
Upper-Case Name Decade of
Debut
Oscar Prestige Bucket USUBJID
1 1 Hans Zimmer Germany Epic MULTI-WINNER Inception 1984 40 8.89999 1.30 31 Yrs HANS ZIMMER 1980s MULTI-WINNER MD-001
2 2 John Williams USA Orchestral LEGEND Star Wars 1958 66 8.80000 0.40 57 Yrs JOHN WILLIAMS 1950s LEGEND MD-002
3 3 A.R. Rahman India World Fusion MULTI-WINNER Slumdog Millionaire 1992 33 8.10000 27.00 23 Yrs A.R. RAHMAN 1990s MULTI-WINNER MD-003
4 4 Alan Menken USA Disney Musicals MULTI-WINNER The Little Mermaid 1979 45 8.00000 0.15 36 Yrs ALAN MENKEN 1970s MULTI-WINNER MD-004
5 5 Danny Elfman USA Gothic Pop NONE Batman 1980 44 7.70000 0.60 35 Yrs DANNY ELFMAN 1980s NONE MD-005
6 6 Ennio Morricone Italy Spaghetti Weste 1 WIN The Good, the Bad… 1961 59 8.50000 0.02 54 Yrs ENNIO MORRICONE 1960s 1 WIN MD-006
7 7 Howard Shore Canada Symphonic MULTI-WINNER The Lord of the Rings 1979 45 8.89999 0.12 36 Yrs HOWARD SHORE 1970s MULTI-WINNER MD-007
8 8 Thomas Newman USA Ambient NONE American Beauty 1984 40 8.30000 0.08 31 Yrs THOMAS NEWMAN 1980s NONE MD-008
9 9 Michael Giacchino USA Eclectic 1 WIN Up 1994 31 8.39999 0.50 21 Yrs MICHAEL GIACCHINO 1990s 1 WIN MD-009
10 10 James Horner USA Romantic MULTI-WINNER Titanic 1979 37 8.89999 0.07 36 Yrs JAMES HORNER 1970s MULTI-WINNER MD-010


title "Data Dictionary – MUSICDIRS";

proc contents data=work.musicdirs position;

run;

title;

Ouput:

Data Dictionary – MUSICDIRS

The CONTENTS Procedure

Data Set Name WORK.MUSICDIRS Observations 20
Member Type DATA Variables 15
Engine V9 Indexes 0
Created 14/09/2015 00:39:15 Observation Length 832
Last Modified 14/09/2015 00:39:15 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 69632
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 83
Obs in First Data Page 20
Number of Data Set Repairs 0
ExtendObsCounter YES
Filename C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD16108_DESKTOP-QFAA4KV_\musicdirs.sas7bdat
Release Created 9.0401M2
Host Created X64_8HOME

Alphabetic List of Variables and Attributes
# Variable Type Len Label
8 ACTIVEYRS Num 8  
9 AVGIMDB Num 4  
11 CAREERSTAGE Char 200 Total Career Length (yrs)
3 COUNTRY Char 20  
7 DEBUTYEAR Num 8  
1 DIRID Num 8  
13 ERAGROUP Char 200 Decade of Debut
2 NAME Char 40  
12 NAME_UP Char 40 Upper-Case Name
6 NOTABLEWORK Char 60  
5 OSCARWINS Num 8  
4 PRIMARYGENRE Char 15  
10 TWITTERM Num 8  
15 USUBJID Char 200  
14 WINLABEL Char 12 Oscar Prestige Bucket

Variables in Creation Order
# Variable Type Len Label
1 DIRID Num 8  
2 NAME Char 40  
3 COUNTRY Char 20  
4 PRIMARYGENRE Char 15  
5 OSCARWINS Num 8  
6 NOTABLEWORK Char 60  
7 DEBUTYEAR Num 8  
8 ACTIVEYRS Num 8  
9 AVGIMDB Num 4  
10 TWITTERM Num 8  
11 CAREERSTAGE Char 200 Total Career Length (yrs)
12 NAME_UP Char 40 Upper-Case Name
13 ERAGROUP Char 200 Decade of Debut
14 WINLABEL Char 12 Oscar Prestige Bucket
15 USUBJID Char 200  

5.PROC SORT + Aggregational Statistics

proc sort data=work.musicdirs out=top_scores ;

   by descending AvgIMDb;

run;


title "Top 5 by Average IMDb Score";

proc print data=top_scores(obs=5);

   var Name Country NotableWork AvgIMDb OscarWins;

   format OscarWins WinLabel.;

run;

Ouput:

Top 5 by Average IMDb Score

Obs NAME COUNTRY NOTABLEWORK AVGIMDB OSCARWINS
1 Ramin Djawadi Germany Game of Thrones 9.30000 NONE
2 Hans Zimmer Germany Inception 8.89999 MULTI-WINNER
3 Howard Shore Canada The Lord of the Rings 8.89999 MULTI-WINNER
4 James Horner USA Titanic 8.89999 MULTI-WINNER
5 John Williams USA Star Wars 8.80000 LEGEND


6 .Ad‑hoc Explorations with PROC MEANS & FREQ

proc means data=work.musicdirs mean maxdec=2 nway noprint;

   class Country;

   var AvgIMDb ActiveYrs TwitterM;

   output out=country_stats mean= / autoname;

run;

Ouput:

Top 5 by Average IMDb Score

Obs COUNTRY _TYPE_ _FREQ_ AVGIMDB_MEAN ACTIVEYRS_MEAN TWITTERM_MEAN
1 Argentina 1 1 7.80000 47.0000 0.1000
2 Canada 1 1 8.89999 45.0000 0.1200
3 France 1 1 8.10000 39.0000 0.0900
4 Germany 1 2 9.09999 30.5000 1.0750
5 Iceland 1 1 8.20000 19.0000 0.4000
6 India 1 1 8.10000 33.0000 27.0000
7 Italy 1 1 8.50000 59.0000 0.0200
8 Scotland 1 1 7.60000 23.0000 0.2300
9 Turkey 1 1 7.20000 21.0000 0.1700
10 UK 1 1 7.90000 39.0000 0.0500
11 USA 1 9 8.30000 37.3333 0.2722


proc freq data=work.musicdirs order=freq;

   tables EraGroup*WinLabel / nopercent norow nocol;

run;

Ouput:

Top 5 by Average IMDb Score

The FREQ Procedure

Frequency
Table of ERAGROUP by WINLABEL
ERAGROUP(Decade of Debut) WINLABEL(Oscar Prestige Bucket)
MULTI-WINNER NONE 1 WIN LEGEND Total
1980s
2
3
1
0
6
2000s
1
3
1
0
5
1970s
4
0
0
0
4
1990s
1
0
1
0
2
1950s
0
0
0
1
1
1960s
0
0
1
0
1
2010s
0
1
0
0
1
Total
8
7
4
1
20


7 .PROC SQL Mastery

proc sql;

   create table genre_summary as

   select PrimaryGenre,

          count(*) as N_Directors,

          mean(AvgIMDb) as MeanIMDb format=5.2,

          sum(TwitterM) as TotalTwtr format=6.1,

          sum(case when OscarWins>0 then 1 else 0 end) as Awarded

   from work.musicdirs

   group by PrimaryGenre

   having calculated N_Directors >= 1

   order by calculated MeanIMDb desc;

quit;

proc print;run;

Ouput:

Obs PRIMARYGENRE N_DIRECTORS MEANIMDB TOTALTWTR AWARDED
1 Epic TV 1 9.30 0.9 0
2 Symphonic 1 8.90 0.1 1
3 Epic 1 8.90 1.3 1
4 Romantic 1 8.90 0.1 1
5 Neo-Classical 1 8.80 0.2 0
6 Orchestral 1 8.80 0.4 1
7 Spaghetti Weste 1 8.50 0.0 1
8 Eclectic 1 8.40 0.5 1
9 Ambient 1 8.30 0.1 0
10 Jazz-Infused 1 8.30 0.3 1
11 Atmospheric 1 8.20 0.4 1
12 Lyric Modern 1 8.10 0.1 1
13 World Fusion 1 8.10 27.0 1
14 Disney Musicals 1 8.00 0.2 1
15 Rom-Drama 1 7.90 0.1 1
16 Latin Fusion 1 7.80 0.1 1
17 Gothic Pop 1 7.70 0.6 0
18 Hybrid 1 7.60 0.2 0
19 Alt-Rock 1 7.50 0.2 0
20 Action-SciFi 1 7.20 0.2 0


8. Reusable Macros – Country Sheets & Genre Posters

8.1 Generate one HTML report per country

%macro country_sheet(ctry);

   %let _uc=%upcase(&ctry);

   ods html file="&sysuserhome.\musicdir_&_uc..html" style=pearl;


   title "Music Directors from &ctry";

   proc report data=work.musicdirs nowd;

      where upcase(Country)="&_uc";

      column Name PrimaryGenre OscarWins WinLabel AvgIMDb CareerStage;

      define WinLabel / style(column)=[foreground=darkblue];

   run;

   ods html close;

%mend;


%country_sheet(USA)

Ouput:

Music Directors from USA

NAME PRIMARYGENRE OSCARWINS Oscar Prestige Bucket AVGIMDB Total Career Length (yrs)
John Williams Orchestral 5 LEGEND 8.7999954 57 Yrs
Alan Menken Disney Musicals 2 MULTI-WINNER 8 36 Yrs
Danny Elfman Gothic Pop 0 NONE 7.6999969 35 Yrs
Thomas Newman Ambient 0 NONE 8.2999954 31 Yrs
Michael Giacchino Eclectic 1 1 WIN 8.3999939 21 Yrs
James Horner Romantic 2 MULTI-WINNER 8.8999939 36 Yrs
Justin Hurwitz Jazz-Infused 2 MULTI-WINNER 8.2999954 6 Yrs
Nicholas Britell Neo-Classical 0 NONE 8.7999954 3 Yrs
Mark Mothersbaugh Alt-Rock 0 NONE 7.5 34 Yrs

%country_sheet(UK)

Ouput:

Music Directors from UK

NAME PRIMARYGENRE OSCARWINS Oscar Prestige Bucket AVGIMDB Total Career Length (yrs)
Rachel Portman Rom-Drama 1 1 WIN 7.8999977 29 Yrs


%country_sheet(Germany)

Ouput:

Music Directors from Germany

NAME PRIMARYGENRE OSCARWINS Oscar Prestige Bucket AVGIMDB Total Career Length (yrs)
Hans Zimmer Epic 2 MULTI-WINNER 8.8999939 31 Yrs
Ramin Djawadi Epic TV 0 NONE 9.2999954 11 Yrs

8.2  Rapid‑fire bar chart macro

%macro bar_genre;

   proc sgplot data=genre_summary;

      vbar PrimaryGenre / response=N_Directors;

      yaxis label="Number of Directors";

      xaxis label="Primary Genre";

      title "Distribution of Genres Among Hollywood Music Directors";

   run;

%mend;

%bar_genre

Log:

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           2.46 seconds

      user cpu time       0.15 seconds

      system cpu time     0.18 seconds

      memory              6359.31k

      OS Memory           19316.00k

      Timestamp           14/09/2015 12:48:33 AM

      Step Count                        37  Switch Count  0


NOTE: Listing image output written to SGPlot.png.

NOTE: There were 20 observations read from the data set WORK.GENRE_SUMMARY.





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

Comments

Popular posts from this blog

409.Can We Build a Reliable Emergency Services Analytics & Fraud Detection System in SAS While Identifying and Fixing Intentional Errors?

397.If a satellite has excellent signal strength but very high latency, can it still deliver good quality communication? Why or why not?A Sas Study

401.How Efficient Are Global Data Centers? A Complete SAS Analytics Study