Wednesday, 9 July 2025

235.ANALYZING DIFFERENT TYPES OF TELEVISION BRANDS USING PROC PRINT | PROC SORT | PROC MEANS | PROC SQL | PROC FREQ | PROC FORMAT | PROC REPORT | PROC TABULATE | PROC TRANSPOSE | PROC UNIVARIATE | PROC GCHART | MACROS IN SAS

ANALYZING DIFFERENT TYPES OF TELEVISION BRANDS USING PROC PRINT | PROC SORT | PROC MEANS | PROC SQL | PROC FREQ | PROC FORMAT | PROC REPORT | PROC TABULATE | PROC TRANSPOSE | PROC UNIVARIATE | PROC GCHART | MACROS IN SAS

 /*Creating A Dataset Of Television Brands*/

Step 1: Setting Global SAS Environment Options

options nocenter nodate pageno=1 linesize=150 pagesize=50 fullstimer;


Step 2: Creating a Custom Format for Categorization

proc format;

    value pricefmt

        low - <20000 = 'Budget'

        20000 - <50000 = 'Mid-Range'

        50000 - high = 'Premium';


    value techfmt

        1 = 'LED'

        2 = 'OLED'

        3 = 'QLED'

        4 = 'Mini-LED'

        5 = 'CRT';


    value yesnofmt

        0 = 'No'

        1 = 'Yes';

run;


Step 3: Creating the Television Brands Dataset

data Television_Brands;

   length Brand $20 Country $15 Resolution $15 OS $20;

   infile datalines  dsd dlm='' truncover;

   input Brand $ Country $ Price Screen_Size Display_Type Smart_TV 

         Resolution & $ OS & $ Ratings Warranty_Years;

   format Price pricefmt. Display_Type techfmt. Smart_TV yesnofmt.;

datalines;

Samsung South_Korea 55000 55 2 1 "4K" "Tizen" 4.5 2

LG South_Korea 62000 65 3 1 "4K" "WebOS" 4.7 3

Sony Japan 70000 55 3 1 "4K" "Android" 4.6 3

Panasonic Japan 45000 50 1 1 "FullHD" "Android" 4.2 2

TCL China 30000 43 1 1 "4K" "Android" 4.3 1

Mi China 28000 40 1 1 "FullHD" "PatchWall" 4.0 1

VU India 25000 43 1 1 "FullHD" "Android" 4.1 1

OnePlus China 35000 50 3 1 "4K" "Android" 4.5 2

Philips Netherlands 48000 50 2 1 "4K" "Saphi" 4.0 2

Haier China 32000 40 1 1 "FullHD" "Android" 3.9 1

Sansui India 20000 32 1 0 "HD Ready" "Linux" 3.8 1

Onida India 23000 32 1 0 "HD Ready" "Android" 3.7 1

Kodak India 21000 32 1 0 "HD Ready" "Linux" 3.6 1

Intex India 19000 32 5 0 "HD Ready" "Linux" 3.5 0.5

Nokia India 34000 43 3 1 "4K" "Android" 4.2 2

Realme China 31000 43 1 1 "FullHD" "Android" 4.1 1

Hisense China 36000 50 2 1 "4K" "Android" 4.4 2

BPL India 22000 32 1 0 "HD Ready" "Linux" 3.4 1

Motorola USA 38000 43 3 1 "4K" "Android" 4.3 2

Sharp Japan 47000 50 2 1 "4K" "Android" 4.2 2

AmazonBasics USA 29000 43 1 1 "FullHD" "Fire OS" 4.1 1

Skyworth China 27000 40 1 1 "FullHD" "Android" 3.8 1

Toshiba Japan 40000 43 2 1 "4K" "Android" 4.0 2

Sanyo Japan 21000 32 1 0 "HD Ready" "Linux" 3.7 1

Detel India 18000 24 5 0 "HD Ready" "Linux" 3.0 0.5

Acer Taiwan 33000 43 1 1 "FullHD" "Android" 4.0 2

;

run;

proc print data=Television_Brands; run;

Output:

Obs Brand Country Resolution OS Price Screen_Size Display_Type Smart_TV Ratings Warranty_Years
1 Samsung South_Korea 4K Tizen Premium 55 OLED Yes 4.5 2.0
2 LG South_Korea 4K WebOS Premium 65 QLED Yes 4.7 3.0
3 Sony Japan 4K Android Premium 55 QLED Yes 4.6 3.0
4 Panasonic Japan FullHD Android Mid-Range 50 LED Yes 4.2 2.0
5 TCL China 4K Android Mid-Range 43 LED Yes 4.3 1.0
6 Mi China FullHD PatchWall Mid-Range 40 LED Yes 4.0 1.0
7 VU India FullHD Android Mid-Range 43 LED Yes 4.1 1.0
8 OnePlus China 4K Android Mid-Range 50 QLED Yes 4.5 2.0
9 Philips Netherlands 4K Saphi Mid-Range 50 OLED Yes 4.0 2.0
10 Haier China FullHD Android Mid-Range 40 LED Yes 3.9 1.0
11 Sansui India HD Ready Linux Mid-Range 32 LED No 3.8 1.0
12 Onida India HD Ready Android Mid-Range 32 LED No 3.7 1.0
13 Kodak India HD Ready Linux Mid-Range 32 LED No 3.6 1.0
14 Intex India HD Ready Linux Budget 32 CRT No 3.5 0.5
15 Nokia India 4K Android Mid-Range 43 QLED Yes 4.2 2.0
16 Realme China FullHD Android Mid-Range 43 LED Yes 4.1 1.0
17 Hisense China 4K Android Mid-Range 50 OLED Yes 4.4 2.0
18 BPL India HD Ready Linux Mid-Range 32 LED No 3.4 1.0
19 Motorola USA 4K Android Mid-Range 43 QLED Yes 4.3 2.0
20 Sharp Japan 4K Android Mid-Range 50 OLED Yes 4.2 2.0
21 AmazonBasics USA FullHD Fire OS Mid-Range 43 LED Yes 4.1 1.0
22 Skyworth China FullHD Android Mid-Range 40 LED Yes 3.8 1.0
23 Toshiba Japan 4K Android Mid-Range 43 OLED Yes 4.0 2.0
24 Sanyo Japan HD Ready Linux Mid-Range 32 LED No 3.7 1.0
25 Detel India HD Ready Linux Budget 24 CRT No 3.0 0.5
26 Acer Taiwan FullHD Android Mid-Range 43 LED Yes 4.0 2.0


Step 4: Viewing the Raw Dataset

proc print data=Television_Brands;

    title "Full List of Television Brands";

run;

Output:

Full List of Television Brands

Obs Brand Country Resolution OS Price Screen_Size Display_Type Smart_TV Ratings Warranty_Years
1 Samsung South_Korea 4K Tizen Premium 55 OLED Yes 4.5 2.0
2 LG South_Korea 4K WebOS Premium 65 QLED Yes 4.7 3.0
3 Sony Japan 4K Android Premium 55 QLED Yes 4.6 3.0
4 Panasonic Japan FullHD Android Mid-Range 50 LED Yes 4.2 2.0
5 TCL China 4K Android Mid-Range 43 LED Yes 4.3 1.0
6 Mi China FullHD PatchWall Mid-Range 40 LED Yes 4.0 1.0
7 VU India FullHD Android Mid-Range 43 LED Yes 4.1 1.0
8 OnePlus China 4K Android Mid-Range 50 QLED Yes 4.5 2.0
9 Philips Netherlands 4K Saphi Mid-Range 50 OLED Yes 4.0 2.0
10 Haier China FullHD Android Mid-Range 40 LED Yes 3.9 1.0
11 Sansui India HD Ready Linux Mid-Range 32 LED No 3.8 1.0
12 Onida India HD Ready Android Mid-Range 32 LED No 3.7 1.0
13 Kodak India HD Ready Linux Mid-Range 32 LED No 3.6 1.0
14 Intex India HD Ready Linux Budget 32 CRT No 3.5 0.5
15 Nokia India 4K Android Mid-Range 43 QLED Yes 4.2 2.0
16 Realme China FullHD Android Mid-Range 43 LED Yes 4.1 1.0
17 Hisense China 4K Android Mid-Range 50 OLED Yes 4.4 2.0
18 BPL India HD Ready Linux Mid-Range 32 LED No 3.4 1.0
19 Motorola USA 4K Android Mid-Range 43 QLED Yes 4.3 2.0
20 Sharp Japan 4K Android Mid-Range 50 OLED Yes 4.2 2.0
21 AmazonBasics USA FullHD Fire OS Mid-Range 43 LED Yes 4.1 1.0
22 Skyworth China FullHD Android Mid-Range 40 LED Yes 3.8 1.0
23 Toshiba Japan 4K Android Mid-Range 43 OLED Yes 4.0 2.0
24 Sanyo Japan HD Ready Linux Mid-Range 32 LED No 3.7 1.0
25 Detel India HD Ready Linux Budget 24 CRT No 3.0 0.5
26 Acer Taiwan FullHD Android Mid-Range 43 LED Yes 4.0 2.0


Step 5: Sorting Dataset by Price (Descending)

proc sort data=Television_Brands out=Sorted_TVs;

    by descending Price;

run;


proc print data=Sorted_TVs (obs=10);

    title "Top 10 Expensive TVs";

run;

Output:

Top 10 Expensive TVs

Obs Brand Country Resolution OS Price Screen_Size Display_Type Smart_TV Ratings Warranty_Years
1 Sony Japan 4K Android Premium 55 QLED Yes 4.6 3
2 LG South_Korea 4K WebOS Premium 65 QLED Yes 4.7 3
3 Samsung South_Korea 4K Tizen Premium 55 OLED Yes 4.5 2
4 Philips Netherlands 4K Saphi Mid-Range 50 OLED Yes 4.0 2
5 Sharp Japan 4K Android Mid-Range 50 OLED Yes 4.2 2
6 Panasonic Japan FullHD Android Mid-Range 50 LED Yes 4.2 2
7 Toshiba Japan 4K Android Mid-Range 43 OLED Yes 4.0 2
8 Motorola USA 4K Android Mid-Range 43 QLED Yes 4.3 2
9 Hisense China 4K Android Mid-Range 50 OLED Yes 4.4 2
10 OnePlus China 4K Android Mid-Range 50 QLED Yes 4.5 2


Step 6: Summary Statistics with PROC MEANS

proc means data=Television_Brands mean min max std;

    var Price Screen_Size Ratings Warranty_Years;

    title "Summary Statistics of TV Attributes";

run;

Output:

Summary Statistics of TV Attributes

The MEANS Procedure

Variable Mean Minimum Maximum Std Dev
Price
Screen_Size
Ratings
Warranty_Years
34192.31
42.5000000
4.0230769
1.5000000
18000.00
24.0000000
3.0000000
0.5000000
70000.00
65.0000000
4.7000000
3.0000000
13511.53
9.2184597
0.3932508
0.6928203


Step 7: Frequency Distribution

proc freq data=Television_Brands;

    tables Country Display_Type Smart_TV Resolution OS / nocum nopercent;

    title "Frequency Table of Categorical Variables";

run;

Output:

Frequency Table of Categorical Variables

The FREQ Procedure

Country Frequency
China 7
India 8
Japan 5
Netherlands 1
South_Korea 2
Taiwan 1
USA 2


Display_Type Frequency
LED 14
OLED 5
QLED 5
CRT 2


Smart_TV Frequency
No 7
Yes 19


Resolution Frequency
4K 11
FullHD 8
HD Ready 7


OS Frequency
Android 15
Fire OS 1
Linux 6
PatchWall 1
Saphi 1
Tizen 1
WebOS 1


Step 8: Using PROC SQL for Custom Queries

a. TVs with Price Above 50,000

proc sql;

    select Brand, Country, Price, Display_Type

    from Television_Brands

    where Price > 50000;

quit;

Output:

Brand Country Price Display_Type
Samsung South_Korea Premium OLED
LG South_Korea Premium QLED
Sony Japan Premium QLED


b. Average Ratings per Country

proc sql;

    select Country, avg(Ratings) as Avg_Rating format=4.2

    from Television_Brands

    group by Country;

quit;

Output:

Country Avg_Rating
China 4.14
India 3.66
Japan 4.14
Netherlands 4.00
South_Korea 4.60
Taiwan 4.00
USA 4.20


Step 9: Reporting with PROC REPORT

proc report data=Television_Brands nowd;

    column Brand Country Price Smart_TV Ratings;

    define Brand / display;

    define Country / group;

    define Price / analysis sum format=8.;

    define Smart_TV / analysis mean;

    define Ratings / analysis mean;

    title "TV Price and Smart Feature Report";

run;

Output:

TV Price and Smart Feature Report

Brand Country Price Smart_TV Ratings
TCL China 30000 Yes 4.3
Mi   28000 Yes 4
OnePlus   35000 Yes 4.5
Haier   32000 Yes 3.9
Realme   31000 Yes 4.1
Hisense   36000 Yes 4.4
Skyworth   27000 Yes 3.8
VU India 25000 Yes 4.1
Sansui   20000 No 3.8
Onida   23000 No 3.7
Kodak   21000 No 3.6
Intex   19000 No 3.5
Nokia   34000 Yes 4.2
BPL   22000 No 3.4
Detel   18000 No 3
Sony Japan 70000 Yes 4.6
Panasonic   45000 Yes 4.2
Sharp   47000 Yes 4.2
Toshiba   40000 Yes 4
Sanyo   21000 No 3.7
Philips Netherlands 48000 Yes 4
Samsung South_Korea 55000 Yes 4.5
LG   62000 Yes 4.7
Acer Taiwan 33000 Yes 4
Motorola USA 38000 Yes 4.3
AmazonBasics   29000 Yes 4.1


Step 10: Tabulation with PROC TABULATE

proc tabulate data=Television_Brands;

    class Country Smart_TV;

    var Price Ratings;

    table Country, Smart_TV*(Price Ratings)*mean;

    title "Cross Tabulation of Price and Ratings by Country and Smart TV Feature";

run;

Output:

Cross Tabulation of Price and Ratings by Country and Smart TV Feature

  Smart_TV
No Yes
Price Ratings Price Ratings
Mean Mean Mean Mean
Country . . 31285.71 4.14
China
India 20500.00 3.50 29500.00 4.15
Japan 21000.00 3.70 50500.00 4.25
Netherlands . . 48000.00 4.00
South_Korea . . 58500.00 4.60
Taiwan . . 33000.00 4.00
USA . . 33500.00 4.20


Step 11: Transposing the Dataset

proc transpose data=Television_Brands out=Trans_TVs;

    var Price Ratings;

    id Brand;

    title "Transposed View of Price and Ratings";

run;

proc print;run;

Output:

Transposed View of Price and Ratings

Obs _NAME_ Samsung LG Sony Panasonic TCL Mi VU OnePlus Philips Haier Sansui Onida Kodak Intex Nokia Realme Hisense BPL Motorola Sharp AmazonBasics Skyworth Toshiba Sanyo Detel Acer
1 Price 55000.0 62000.0 70000.0 45000.0 30000.0 28000 25000.0 35000.0 48000 32000.0 20000.0 23000.0 21000.0 19000.0 34000.0 31000.0 36000.0 22000.0 38000.0 47000.0 29000.0 27000.0 40000 21000.0 18000 33000
2 Ratings 4.5 4.7 4.6 4.2 4.3 4 4.1 4.5 4 3.9 3.8 3.7 3.6 3.5 4.2 4.1 4.4 3.4 4.3 4.2 4.1 3.8 4 3.7 3 4


Step 12: Distribution Check with PROC UNIVARIATE

proc univariate data=Television_Brands;

    var Price;

    histogram / normal;

    title "Price Distribution of Televisions";

run;

Output:

Price Distribution of Televisions

The UNIVARIATE Procedure
Fitted Normal Distribution for Price

Parameters for Normal Distribution
Parameter Symbol Estimate
Mean Mu 34192.31
Std Dev Sigma 13511.53


Goodness-of-Fit Tests for Normal Distribution
Test Statistic p Value
Kolmogorov-Smirnov D 0.13909247 Pr > D >0.150
Cramer-von Mises W-Sq 0.11388983 Pr > W-Sq 0.073
Anderson-Darling A-Sq 0.73765762 Pr > A-Sq 0.048


Quantiles for Normal Distribution
Percent Quantile
Observed Estimated
1.0 18000.0 2759.78
5.0 19000.0 11967.81
10.0 20000.0 16876.58
25.0 23000.0 25078.92
50.0 31500.0 34192.31
75.0 40000.0 43305.70
90.0 55000.0 51508.03
95.0 62000.0 56416.80
99.0 70000.0 65624.84


Step 13: Graphing with PROC GCHART

proc gchart data=Television_Brands;

    vbar Country / sumvar=Price type=mean;

    title "Average TV Price by Country";

run;

Log:

NOTE: 18277 bytes written to C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD10832_DESKTOP-QFAA4KV_\gchart.png.


Step 14: SAS Macro for Brand Info by Display Type

%macro TVsByDisplay(display);

    proc sql;

        select Brand, Price, Ratings

        from Television_Brands

        where Display_Type = &display;

    quit;

%mend;


%TVsByDisplay(3); 

Output:

Brand Price Ratings
LG Premium 4.7
Sony Premium 4.6
OnePlus Mid-Range 4.5
Nokia Mid-Range 4.2
Motorola Mid-Range 4.3


Step 15: Creating Derived Variable – Price per Inch

data Television_Brands;

    set Television_Brands;

    Price_Per_Inch = round(Price / Screen_Size, .1);

run;


proc print data=Television_Brands(obs=10);

    var Brand Screen_Size Price Price_Per_Inch;

    title "TVs with Calculated Price per Inch";

run;

Output:

TVs with Calculated Price per Inch

Obs Brand Screen_Size Price Price_Per_Inch
1 Samsung 55 Premium 1000.0
2 LG 65 Premium 953.8
3 Sony 55 Premium 1272.7
4 Panasonic 50 Mid-Range 900.0
5 TCL 43 Mid-Range 697.7
6 Mi 40 Mid-Range 700.0
7 VU 43 Mid-Range 581.4
8 OnePlus 50 Mid-Range 700.0
9 Philips 50 Mid-Range 960.0
10 Haier 40 Mid-Range 800.0


Step 16: Group Summary by OS

proc sql;

    select OS, count(*) as Count_TVs, avg(Ratings) as Avg_Rating format=4.2

    from Television_Brands

    group by OS

    order by Avg_Rating desc;

quit;

Output:

OS Count_TVs Avg_Rating
WebOS 1 4.70
Tizen 1 4.50
Android 15 4.15
Fire OS 1 4.10
Saphi 1 4.00
PatchWall 1 4.00
Linux 6 3.50


Step 17: Filtering TVs with Ratings Above 4.2

data HighRated;

    set Television_Brands;

    if Ratings >= 4.2;

run;


proc print data=HighRated;

    title "Televisions with Ratings ≥ 4.2";

run;

Output:
Televisions with Ratings = 4.2

Obs Brand Country Resolution OS Price Screen_Size Display_Type Smart_TV Ratings Warranty_Years Price_Per_Inch
1 Samsung South_Korea 4K Tizen Premium 55 OLED Yes 4.5 2 1000.0
2 LG South_Korea 4K WebOS Premium 65 QLED Yes 4.7 3 953.8
3 Sony Japan 4K Android Premium 55 QLED Yes 4.6 3 1272.7
4 Panasonic Japan FullHD Android Mid-Range 50 LED Yes 4.2 2 900.0
5 TCL China 4K Android Mid-Range 43 LED Yes 4.3 1 697.7
6 OnePlus China 4K Android Mid-Range 50 QLED Yes 4.5 2 700.0
7 Nokia India 4K Android Mid-Range 43 QLED Yes 4.2 2 790.7
8 Hisense China 4K Android Mid-Range 50 OLED Yes 4.4 2 720.0
9 Motorola USA 4K Android Mid-Range 43 QLED Yes 4.3 2 883.7
10 Sharp Japan 4K Android Mid-Range 50 OLED Yes 4.2 2 940.0    





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




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

PLEASE FOLLOW OUR TELEGRAM CHANNEL CLICK HERE

PLEASE FOLLOW OUR FACEBOOK PAGE  CLICK HERE

PLEASE FOLLOW OUR INSTAGRAM PAGE CLICK HERE









No comments:

Post a Comment