Thursday, 18 September 2025

290.REALWORLD VIBE DATASET - PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC SORT | PROC REPORT | PROC TABULATE | PROC SGPLOT | PROC CONTENTS | PROC FORMAT | MACRO | AUTOMATION & ANALYSIS

REALWORLD VIBE DATASET - PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC SORT | PROC REPORT | PROC TABULATE | PROC SGPLOT | PROC CONTENTS  | PROC FORMAT  | MACRO | AUTOMATION & ANALYSIS

options nodate nonumber validvarname=any;

options nocenter;

1) Create the dataset with 7 variables and 12 observations 

data work.vibe;

    infile datalines dlm='|' dsd truncover;

    length VibeID $8 Location $30 Genre $20 EventDate 8;

    format TicketPrice dollar8.2 EventDate yymmdd10.;

/*     Variables:*/

/*       VibeID       - unique ID (string)*/

/*       Location     - city/venue*/

/*       Genre        - music/style (e.g., Indie, EDM, Jazz)*/

/*       Energy       - numeric scale 1-10 (higher = more energetic)*/

/*       CrowdSize    - numeric count of attendees*/

/*       AvgAge       - average attendee age (years)*/

/*       TicketPrice  - numeric (INR/USD formatting)*/

/*       EventDate    - date of event (formatted)*/

/*    */

    input VibeID $ Location :$30. Genre :$20. Energy CrowdSize AvgAge TicketPrice EventDate :yymmdd10.;

datalines;

V001|Hyderabad - Warehouse|EDM|9|1200|24|25.00|2025-07-10

V002|Mumbai - OpenGround|Bollywood|8|5000|28|12.00|2025-08-05

V003|Bengaluru - Cafe 9|Indie|6|180|26|8.00|2025-03-21

V004|Chennai - Beach Fest|Fusion|7|2200|29|15.00|2024-12-14

V005|Kolkata - Jazz Club|Jazz|5|140|42|18.00|2025-02-10

V006|Pune - Craft Hall|Metal|8|800|22|20.00|2025-06-02

V007|Goa - Sunset Stage|Reggae|7|3500|30|10.00|2025-01-20

V008|Delhi - Rooftop|Pop|7|900|27|14.00|2025-04-18

V009|Lucknow - Heritage|Folk|4|300|36|6.00|2024-11-24

V010|Jaipur - Palace Grounds|Classical|3|200|48|22.00|2025-09-01

V011|Hyderabad - IndieHouse|Indie|6|220|25|9.00|2025-05-15

V012|Mumbai - NightMarket|EDM|9|4500|23|18.00|2025-08-22

;

run;


Purpose: display the dataset rows for quick inspection 

proc print data=work.vibe noobs label;

    title "VIBE DATA - RAW";

    var VibeID Location Genre EventDate Energy CrowdSize AvgAge TicketPrice;

run;

Output:

VIBE DATA - RAW

VibeIDLocationGenreEventDateEnergyCrowdSizeAvgAgeTicketPrice
V001Hyderabad - WarehouseEDM2025-07-109120024$25.00
V002Mumbai - OpenGroundBollywood2025-08-058500028$12.00
V003Bengaluru - Cafe 9Indie2025-03-21618026$8.00
V004Chennai - Beach FestFusion2024-12-147220029$15.00
V005Kolkata - Jazz ClubJazz2025-02-10514042$18.00
V006Pune - Craft HallMetal2025-06-02880022$20.00
V007Goa - Sunset StageReggae2025-01-207350030$10.00
V008Delhi - RooftopPop2025-04-18790027$14.00
V009Lucknow - HeritageFolk2024-11-24430036$6.00
V010Jaipur - Palace GroundsClassical2025-09-01320048$22.00
V011Hyderabad - IndieHouseIndie2025-05-15622025$9.00
V012Mumbai - NightMarketEDM2025-08-229450023$18.00

2) PROC MEANS for numeric summary 

Purpose: compute central tendency and spread for numeric variables 

proc means data=work.vibe n mean median std min max maxdec=2;

    var Energy CrowdSize AvgAge TicketPrice;

    title "NUMERIC SUMMARY - PROC MEANS";

run;

Output:

NUMERIC SUMMARY - PROC MEANS

The MEANS Procedure

VariableNMeanMedianStd DevMinimumMaximum
Energy
CrowdSize
AvgAge
TicketPrice
12
12
12
12
6.58
1595.00
30.00
14.75
7.00
850.00
27.50
14.50
1.88
1782.03
8.02
5.97
3.00
140.00
22.00
6.00
9.00
5000.00
48.00
25.00

3) PROC FREQ for categorical distributions 

Purpose: count frequencies of categorical variables 

proc freq data=work.vibe;

    tables Genre Location / nocum nopercent;

    title "FREQUENCY DISTRIBUTIONS - PROC FREQ";

run;

Output:

FREQUENCY DISTRIBUTIONS - PROC FREQ

The FREQ Procedure

GenreFrequency
Bollywood1
Classical1
EDM2
Folk1
Fusion1
Indie2
Jazz1
Metal1
Pop1
Reggae1
LocationFrequency
Bengaluru - Cafe 91
Chennai - Beach Fest1
Delhi - Rooftop1
Goa - Sunset Stage1
Hyderabad - IndieHouse1
Hyderabad - Warehouse1
Jaipur - Palace Grounds1
Kolkata - Jazz Club1
Lucknow - Heritage1
Mumbai - NightMarket1
Mumbai - OpenGround1
Pune - Craft Hall1

4) PROC SQL to create a summary table and flagged records 

Purpose: use SQL to create aggregated summaries and conditional subsets 

proc sql;

    create table work.vibe_summary as

    select Genre,

           count(*) as N,

           round(mean(Energy),.01) as AvgEnergy,

           round(mean(CrowdSize),1) as AvgCrowd,

           round(mean(TicketPrice),.01) as AvgTicket

    from work.vibe

    group by Genre

    order by AvgEnergy desc;

quit;

proc print;run;

Output:

ObsGenreNAvgEnergyAvgCrowdAvgTicket
1EDM29285021.5
2Bollywood18500012.0
3Metal1880020.0
4Reggae17350010.0
5Fusion17220015.0
6Pop1790014.0
7Indie262008.5
8Jazz1514018.0
9Folk143006.0
10Classical1320022.0


5) Create flagged high-energy/popular events using SQL 

proc sql;

    create table work.high_vibes as

    select *, 

           case when Energy >= 8 and CrowdSize >= 800 then 'HIGH' 

                when Energy >=7 and CrowdSize >=300 then 'MEDIUM' else 'LOW' end as VibeLevel

    from work.vibe

    order by Energy desc, CrowdSize desc;

quit;

proc print;run;

Output:

ObsVibeIDLocationGenreEventDateTicketPriceEnergyCrowdSizeAvgAgeVibeLevel
1V012Mumbai - NightMarketEDM2025-08-22$18.009450023HIGH
2V001Hyderabad - WarehouseEDM2025-07-10$25.009120024HIGH
3V002Mumbai - OpenGroundBollywood2025-08-05$12.008500028HIGH
4V006Pune - Craft HallMetal2025-06-02$20.00880022HIGH
5V007Goa - Sunset StageReggae2025-01-20$10.007350030MEDIUM
6V004Chennai - Beach FestFusion2024-12-14$15.007220029MEDIUM
7V008Delhi - RooftopPop2025-04-18$14.00790027MEDIUM
8V011Hyderabad - IndieHouseIndie2025-05-15$9.00622025LOW
9V003Bengaluru - Cafe 9Indie2025-03-21$8.00618026LOW
10V005Kolkata - Jazz ClubJazz2025-02-10$18.00514042LOW
11V009Lucknow - HeritageFolk2024-11-24$6.00430036LOW
12V010Jaipur - Palace GroundsClassical2025-09-01$22.00320048LOW


6) PROC SORT for preparing reports 

Purpose: sort the dataset by EventDate to produce chronological outputs 

proc sort data=work.vibe out=work.vibe_sorted;

    by EventDate;

run;

proc print;run;

Output:

ObsVibeIDLocationGenreEventDateTicketPriceEnergyCrowdSizeAvgAge
1V009Lucknow - HeritageFolk2024-11-24$6.00430036
2V004Chennai - Beach FestFusion2024-12-14$15.007220029
3V007Goa - Sunset StageReggae2025-01-20$10.007350030
4V005Kolkata - Jazz ClubJazz2025-02-10$18.00514042
5V003Bengaluru - Cafe 9Indie2025-03-21$8.00618026
6V008Delhi - RooftopPop2025-04-18$14.00790027
7V011Hyderabad - IndieHouseIndie2025-05-15$9.00622025
8V006Pune - Craft HallMetal2025-06-02$20.00880022
9V001Hyderabad - WarehouseEDM2025-07-10$25.009120024
10V002Mumbai - OpenGroundBollywood2025-08-05$12.008500028
11V012Mumbai - NightMarketEDM2025-08-22$18.009450023
12V010Jaipur - Palace GroundsClassical2025-09-01$22.00320048


7) PROC REPORT to produce a formatted report 

Purpose: show a nicely formatted summary report with computed columns 

proc report data=work.vibe nowd split='|' headline headskip;

    column Genre VibeID Location EventDate Energy CrowdSize AvgAge TicketPrice;

    define Genre / group 'GENRE';

    define VibeID / display 'ID';

    define Location / display 'LOCATION';

    define EventDate / display 'EVENT DATE' format=yymmdd10.;

    define Energy / analysis mean 'ENERGY';

    define CrowdSize / analysis sum format=8. 'TOTAL CROWD';

    define AvgAge / analysis mean 'AVG AGE';

    define TicketPrice / analysis mean format=dollar8.2 'AVG TICKET';

    title "VIBE SUMMARY REPORT - PROC REPORT";

run;

Output:

VIBE SUMMARY REPORT - PROC REPORT

GENREIDLOCATIONEVENT DATEENERGYTOTAL CROWDAVG AGEAVG TICKET
BollywoodV002Mumbai - OpenGround2025-08-058500028$12.00
ClassicalV010Jaipur - Palace Grounds2025-09-01320048$22.00
EDMV001Hyderabad - Warehouse2025-07-109120024$25.00
 V012Mumbai - NightMarket2025-08-229450023$18.00
FolkV009Lucknow - Heritage2024-11-24430036$6.00
FusionV004Chennai - Beach Fest2024-12-147220029$15.00
IndieV003Bengaluru - Cafe 92025-03-21618026$8.00
 V011Hyderabad - IndieHouse2025-05-15622025$9.00
JazzV005Kolkata - Jazz Club2025-02-10514042$18.00
MetalV006Pune - Craft Hall2025-06-02880022$20.00
PopV008Delhi - Rooftop2025-04-18790027$14.00
ReggaeV007Goa - Sunset Stage2025-01-207350030$10.00

8) PROC TABULATE for multi-dimensional summaries 

Purpose: compact multi-variable table of counts and means 

proc tabulate data=work.vibe;

    class Genre;

    var Energy CrowdSize TicketPrice;

    table Genre,

          N='Count'

          Energy*mean='Mean Energy'*f=6.2

          CrowdSize*mean='Mean Crowd'*f=8.1

          TicketPrice*mean='Mean Ticket'*f=dollar8.2;

    title "MULTI-DIMENSIONAL SUMMARY - PROC TABULATE";

run;

Output:

MULTI-DIMENSIONAL SUMMARY - PROC TABULATE

 CountEnergyCrowdSizeTicketPrice
Mean EnergyMean CrowdMean Ticket
Genre18.005000.0$12.00
Bollywood
Classical13.00200.0$22.00
EDM29.002850.0$21.50
Folk14.00300.0$6.00
Fusion17.002200.0$15.00
Indie26.00200.0$8.50
Jazz15.00140.0$18.00
Metal18.00800.0$20.00
Pop17.00900.0$14.00
Reggae17.003500.0$10.00

9) Simple PROC SGPLOT for a scatter of Energy vs CrowdSize 

Purpose: visualize relationship between energy and crowd size 

proc sgplot data=work.vibe;

    title "ENERGY vs CROWD SIZE - PROC SGPLOT";

    scatter x=Energy y=CrowdSize / markerattrs=(symbol=CircleFilled size=8);

    reg x=Energy y=CrowdSize; /* trend line */

    xaxis label="Energy (1-10)";

    yaxis label="Crowd Size";

run;

Output:



10) Macro to produce repeated analysis for a given genre 

Purpose: reusable macro to filter by genre and run print+means 

%macro vibe_by_genre(g=Indie);

    %put NOTE: Running Vibe analysis for genre=&g;

    proc sql;

       create table work.vibe_&g as

       select * from work.vibe where upcase(Genre)=upcase("&g");

    quit;

    proc print data=work.vibe_&g noobs;

       title "Vibe - Genre: &g";

    run;

    proc means data=work.vibe_&g n mean std min max maxdec=2;

       var Energy CrowdSize AvgAge TicketPrice;

       title "Numeric Summary - Genre: &g";

    run;

%mend vibe_by_genre;

11) Demonstrate using the macro to run for 'EDM' and 'Indie' 

%vibe_by_genre(g=EDM);

Output:

Vibe - Genre: EDM

VibeIDLocationGenreEventDateTicketPriceEnergyCrowdSizeAvgAge
V001Hyderabad - WarehouseEDM2025-07-10$25.009120024
V012Mumbai - NightMarketEDM2025-08-22$18.009450023

Numeric Summary - Genre: EDM

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
Energy
CrowdSize
AvgAge
TicketPrice
2
2
2
2
9.00
2850.00
23.50
21.50
0.00
2333.45
0.71
4.95
9.00
1200.00
23.00
18.00
9.00
4500.00
24.00
25.00

%vibe_by_genre(g=Indie);

Output:

Vibe - Genre: Indie

VibeIDLocationGenreEventDateTicketPriceEnergyCrowdSizeAvgAge
V003Bengaluru - Cafe 9Indie2025-03-21$8.00618026
V011Hyderabad - IndieHouseIndie2025-05-15$9.00622025

Numeric Summary - Genre: Indie

The MEANS Procedure

VariableNMeanStd DevMinimumMaximum
Energy
CrowdSize
AvgAge
TicketPrice
2
2
2
2
6.00
200.00
25.50
8.50
0.00
28.28
0.71
0.71
6.00
180.00
25.00
8.00
6.00
220.00
26.00
9.00

 12) Macro to auto-generate summary CSV for all genres via PROC SQL loop 

 Purpose: loop over distinct genres and output summaries into work.genre_summaries 

proc sql noprint;

    select distinct Genre into :g1-:g99 from work.vibe;

    %let gcount=&sqlobs;

quit;


%macro genre_summaries;

    %if &gcount = 0 %then %do;

        %put WARNING: No genres found!;

    %end;

    %else %do i=1 %to &gcount;

        %let thisg=&&g&i;

        proc sql;

            create table work.summary_&i as

            select "&thisg" as Genre,

                   count(*) as N,

                   round(mean(Energy),.01) as AvgEnergy,

                   round(mean(CrowdSize),1) as AvgCrowd,

                   round(mean(TicketPrice),.01) as AvgTicket

            from work.vibe

            where Genre = "&thisg";

        quit;

proc print;run;

    %end;

     Combine 

    data work.genre_summaries;

        set work.summary_:;

    run;

proc print;run;

%mend genre_summaries;


%genre_summaries

Output:

ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Bollywood18500012
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Classical1320022
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1EDM29285021.5
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Folk143006
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Fusion17220015
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Indie262008.5
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Jazz1514018
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Metal1880020
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Pop1790014
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Reggae17350010
ObsGenreNAvgEnergyAvgCrowdAvgTicket
1Reggae17350010



To Visit My Previous Online Streaming Flatform Dataset:Click Here
To Visit My Previous Statistical Evaluation Of Clinical Trials:Click Here
To Visit My Previous Unlocking Retail Insights Dataset:Click Here
To Visit My Previous Sas Interview Questions-1:Click Here  



Follow Us On : 


 


--- FOLLOW OUR BLOG FOR MORE INFORMATION.

--->PLEASE DO COMMENTS AND SHARE OUR BLOG.

No comments:

Post a Comment