200.SAS ELECTRONICS DATA ANALYSIS USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC REPORT | PROC FORMAT | PROC SGPLOT | PROC RANK | PROC EXPORT | PROC TRANSPOSE | PROC UNIVARIATE | PROC TABULATE
- Get link
- X
- Other Apps
SAS ELECTRONICS DATA ANALYSIS USING PROC PRINT | PROC MEANS | PROC FREQ | PROC SQL | PROC REPORT | PROC FORMAT | PROC SGPLOT | PROC RANK | PROC EXPORT | PROC TRANSPOSE | PROC UNIVARIATE | PROC TABULATE
/*A unique and creative SAS project involving different types of electronics*/
Step 1: Create Electronics Dataset
data Electronics_Data;
length Product_ID $5 Product_Name $20 Category $15 Brand $15 Availability $10;
input Product_ID $ Product_Name $ Category $ Brand $ Price Warranty_Years
Power_Consumption Weight Ratings Availability $ Launch_Year;
datalines;
E001 Galaxy_S21 Mobile Samsung 69999 2 15 0.169 4.5 InStock 2021
E002 MacBook_Pro Laptop Apple 129999 3 65 1.4 4.8 InStock 2022
E003 Bravia_4K TV Sony 84999 2 110 8.0 4.4 OutOfStock 2020
E004 Mi_Band_6 Watch Xiaomi 3499 1 5 0.035 4.2 InStock 2021
E005 Surface_Pro Tablet Microsoft 99999 2 30 0.8 4.6 InStock 2023
E006 JBL_Flip5 Speaker JBL 6999 1 10 0.5 4.3 InStock 2020
E007 OnePlus_9 Mobile OnePlus 49999 2 18 0.197 4.4 InStock 2021
E008 ThinkPad_X1 Laptop Lenovo 114999 3 60 1.2 4.7 OutOfStock 2022
E009 OLED_TV TV LG 134999 2 120 9.5 4.6 InStock 2021
E010 Galaxy_Tab Tablet Samsung 54999 2 20 0.6 4.1 InStock 2022
E011 iPhone_13 Mobile Apple 79999 2 17 0.174 4.9 InStock 2022
E012 Pixel_6 Mobile Google 59999 2 16 0.178 4.5 OutOfStock 2021
E013 Echo_Dot Speaker Amazon 3499 1 6 0.3 4.2 InStock 2020
E014 Realme_Book Laptop Realme 49999 2 55 1.3 4.0 InStock 2023
E015 QLED_TV TV TCL 74999 2 100 7.5 4.3 InStock 2022
E016 iPad_Pro Tablet Apple 109999 2 25 0.7 4.8 OutOfStock 2023
E017 Watch_Series_7 Watch Apple 41999 2 6 0.042 4.6 InStock 2022
;
run;
proc print;run;
Output:
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | E001 | Galaxy_S21 | Mobile | Samsung | InStock | 69999 | 2 | 15 | 0.169 | 4.5 | 2021 |
2 | E002 | MacBook_Pro | Laptop | Apple | InStock | 129999 | 3 | 65 | 1.400 | 4.8 | 2022 |
3 | E003 | Bravia_4K | TV | Sony | OutOfStock | 84999 | 2 | 110 | 8.000 | 4.4 | 2020 |
4 | E004 | Mi_Band_6 | Watch | Xiaomi | InStock | 3499 | 1 | 5 | 0.035 | 4.2 | 2021 |
5 | E005 | Surface_Pro | Tablet | Microsoft | InStock | 99999 | 2 | 30 | 0.800 | 4.6 | 2023 |
6 | E006 | JBL_Flip5 | Speaker | JBL | InStock | 6999 | 1 | 10 | 0.500 | 4.3 | 2020 |
7 | E007 | OnePlus_9 | Mobile | OnePlus | InStock | 49999 | 2 | 18 | 0.197 | 4.4 | 2021 |
8 | E008 | ThinkPad_X1 | Laptop | Lenovo | OutOfStock | 114999 | 3 | 60 | 1.200 | 4.7 | 2022 |
9 | E009 | OLED_TV | TV | LG | InStock | 134999 | 2 | 120 | 9.500 | 4.6 | 2021 |
10 | E010 | Galaxy_Tab | Tablet | Samsung | InStock | 54999 | 2 | 20 | 0.600 | 4.1 | 2022 |
11 | E011 | iPhone_13 | Mobile | Apple | InStock | 79999 | 2 | 17 | 0.174 | 4.9 | 2022 |
12 | E012 | Pixel_6 | Mobile | OutOfStock | 59999 | 2 | 16 | 0.178 | 4.5 | 2021 | |
13 | E013 | Echo_Dot | Speaker | Amazon | InStock | 3499 | 1 | 6 | 0.300 | 4.2 | 2020 |
14 | E014 | Realme_Book | Laptop | Realme | InStock | 49999 | 2 | 55 | 1.300 | 4.0 | 2023 |
15 | E015 | QLED_TV | TV | TCL | InStock | 74999 | 2 | 100 | 7.500 | 4.3 | 2022 |
16 | E016 | iPad_Pro | Tablet | Apple | OutOfStock | 109999 | 2 | 25 | 0.700 | 4.8 | 2023 |
17 | E017 | Watch_Series_7 | Watch | Apple | InStock | 41999 | 2 | 6 | 0.042 | 4.6 | 2022 |
Step 2: PROC CONTENTS and PROC PRINT
proc contents data=Electronics_Data;
title "Structure of Electronics Dataset";
run;
Output:
Structure of Electronics Dataset |
Data Set Name | WORK.ELECTRONICS_DATA | Observations | 17 |
---|---|---|---|
Member Type | DATA | Variables | 11 |
Engine | V9 | Indexes | 0 |
Created | 14/09/2015 00:03:19 | Observation Length | 120 |
Last Modified | 14/09/2015 00:03:19 | 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 | 545 |
Obs in First Data Page | 17 |
Number of Data Set Repairs | 0 |
ExtendObsCounter | YES |
Filename | C:\Users\Lenovo\AppData\Local\Temp\SAS Temporary Files\_TD2096_DESKTOP-QFAA4KV_\electronics_data.sas7bdat |
Release Created | 9.0401M2 |
Host Created | X64_8HOME |
Alphabetic List of Variables and Attributes | |||
---|---|---|---|
# | Variable | Type | Len |
5 | Availability | Char | 10 |
4 | Brand | Char | 15 |
3 | Category | Char | 15 |
11 | Launch_Year | Num | 8 |
8 | Power_Consumption | Num | 8 |
6 | Price | Num | 8 |
1 | Product_ID | Char | 5 |
2 | Product_Name | Char | 20 |
10 | Ratings | Num | 8 |
7 | Warranty_Years | Num | 8 |
9 | Weight | Num | 8 |
proc print data=Electronics_Data;
title "Complete Electronics Dataset";
run;
Output:
Complete Electronics Dataset |
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | E001 | Galaxy_S21 | Mobile | Samsung | InStock | 69999 | 2 | 15 | 0.169 | 4.5 | 2021 |
2 | E002 | MacBook_Pro | Laptop | Apple | InStock | 129999 | 3 | 65 | 1.400 | 4.8 | 2022 |
3 | E003 | Bravia_4K | TV | Sony | OutOfStock | 84999 | 2 | 110 | 8.000 | 4.4 | 2020 |
4 | E004 | Mi_Band_6 | Watch | Xiaomi | InStock | 3499 | 1 | 5 | 0.035 | 4.2 | 2021 |
5 | E005 | Surface_Pro | Tablet | Microsoft | InStock | 99999 | 2 | 30 | 0.800 | 4.6 | 2023 |
6 | E006 | JBL_Flip5 | Speaker | JBL | InStock | 6999 | 1 | 10 | 0.500 | 4.3 | 2020 |
7 | E007 | OnePlus_9 | Mobile | OnePlus | InStock | 49999 | 2 | 18 | 0.197 | 4.4 | 2021 |
8 | E008 | ThinkPad_X1 | Laptop | Lenovo | OutOfStock | 114999 | 3 | 60 | 1.200 | 4.7 | 2022 |
9 | E009 | OLED_TV | TV | LG | InStock | 134999 | 2 | 120 | 9.500 | 4.6 | 2021 |
10 | E010 | Galaxy_Tab | Tablet | Samsung | InStock | 54999 | 2 | 20 | 0.600 | 4.1 | 2022 |
11 | E011 | iPhone_13 | Mobile | Apple | InStock | 79999 | 2 | 17 | 0.174 | 4.9 | 2022 |
12 | E012 | Pixel_6 | Mobile | OutOfStock | 59999 | 2 | 16 | 0.178 | 4.5 | 2021 | |
13 | E013 | Echo_Dot | Speaker | Amazon | InStock | 3499 | 1 | 6 | 0.300 | 4.2 | 2020 |
14 | E014 | Realme_Book | Laptop | Realme | InStock | 49999 | 2 | 55 | 1.300 | 4.0 | 2023 |
15 | E015 | QLED_TV | TV | TCL | InStock | 74999 | 2 | 100 | 7.500 | 4.3 | 2022 |
16 | E016 | iPad_Pro | Tablet | Apple | OutOfStock | 109999 | 2 | 25 | 0.700 | 4.8 | 2023 |
17 | E017 | Watch_Series_7 | Watch | Apple | InStock | 41999 | 2 | 6 | 0.042 | 4.6 | 2022 |
Step 3: PROC MEANS and PROC FREQ
proc means data=Electronics_Data mean std min max;
var Price Warranty_Years Power_Consumption Weight Ratings;
title "Descriptive Statistics of Electronics Variables";
run;
Output:
Descriptive Statistics of Electronics Variables |
Variable | Mean | Std Dev | Minimum | Maximum | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
proc freq data=Electronics_Data;
tables Category Brand Availability / nocum nopercent;
title "Frequency of Electronics by Category, Brand, and Availability";
run;
Output:
Frequency of Electronics by Category, Brand, and Availability |
Category | Frequency |
---|---|
Laptop | 3 |
Mobile | 4 |
Speaker | 2 |
TV | 3 |
Tablet | 3 |
Watch | 2 |
Brand | Frequency |
---|---|
Amazon | 1 |
Apple | 4 |
1 | |
JBL | 1 |
LG | 1 |
Lenovo | 1 |
Microsoft | 1 |
OnePlus | 1 |
Realme | 1 |
Samsung | 2 |
Sony | 1 |
TCL | 1 |
Xiaomi | 1 |
Availability | Frequency |
---|---|
InStock | 13 |
OutOfStock | 4 |
Step 4: PROC SORT and PROC UNIVARIATE
proc sort data=Electronics_Data out=Sorted_Electronics;
by descending Price;
run;
proc print;run;
Output:
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | E009 | OLED_TV | TV | LG | InStock | 134999 | 2 | 120 | 9.500 | 4.6 | 2021 |
2 | E002 | MacBook_Pro | Laptop | Apple | InStock | 129999 | 3 | 65 | 1.400 | 4.8 | 2022 |
3 | E008 | ThinkPad_X1 | Laptop | Lenovo | OutOfStock | 114999 | 3 | 60 | 1.200 | 4.7 | 2022 |
4 | E016 | iPad_Pro | Tablet | Apple | OutOfStock | 109999 | 2 | 25 | 0.700 | 4.8 | 2023 |
5 | E005 | Surface_Pro | Tablet | Microsoft | InStock | 99999 | 2 | 30 | 0.800 | 4.6 | 2023 |
6 | E003 | Bravia_4K | TV | Sony | OutOfStock | 84999 | 2 | 110 | 8.000 | 4.4 | 2020 |
7 | E011 | iPhone_13 | Mobile | Apple | InStock | 79999 | 2 | 17 | 0.174 | 4.9 | 2022 |
8 | E015 | QLED_TV | TV | TCL | InStock | 74999 | 2 | 100 | 7.500 | 4.3 | 2022 |
9 | E001 | Galaxy_S21 | Mobile | Samsung | InStock | 69999 | 2 | 15 | 0.169 | 4.5 | 2021 |
10 | E012 | Pixel_6 | Mobile | OutOfStock | 59999 | 2 | 16 | 0.178 | 4.5 | 2021 | |
11 | E010 | Galaxy_Tab | Tablet | Samsung | InStock | 54999 | 2 | 20 | 0.600 | 4.1 | 2022 |
12 | E007 | OnePlus_9 | Mobile | OnePlus | InStock | 49999 | 2 | 18 | 0.197 | 4.4 | 2021 |
13 | E014 | Realme_Book | Laptop | Realme | InStock | 49999 | 2 | 55 | 1.300 | 4.0 | 2023 |
14 | E017 | Watch_Series_7 | Watch | Apple | InStock | 41999 | 2 | 6 | 0.042 | 4.6 | 2022 |
15 | E006 | JBL_Flip5 | Speaker | JBL | InStock | 6999 | 1 | 10 | 0.500 | 4.3 | 2020 |
16 | E004 | Mi_Band_6 | Watch | Xiaomi | InStock | 3499 | 1 | 5 | 0.035 | 4.2 | 2021 |
17 | E013 | Echo_Dot | Speaker | Amazon | InStock | 3499 | 1 | 6 | 0.300 | 4.2 | 2020 |
proc univariate data=Electronics_Data;
var Ratings;
histogram Ratings / normal;
title "Distribution of Product Ratings";
run;
Output:
Distribution of Product Ratings |
Parameters for Normal Distribution | ||
---|---|---|
Parameter | Symbol | Estimate |
Mean | Mu | 4.464706 |
Std Dev | Sigma | 0.259666 |
Goodness-of-Fit Tests for Normal Distribution | ||||
---|---|---|---|---|
Test | Statistic | p Value | ||
Kolmogorov-Smirnov | D | 0.11059218 | Pr > D | >0.150 |
Cramer-von Mises | W-Sq | 0.02806871 | Pr > W-Sq | >0.250 |
Anderson-Darling | A-Sq | 0.18511997 | Pr > A-Sq | >0.250 |
Quantiles for Normal Distribution | ||
---|---|---|
Percent | Quantile | |
Observed | Estimated | |
1.0 | 4.00000 | 3.86063 |
5.0 | 4.00000 | 4.03759 |
10.0 | 4.10000 | 4.13193 |
25.0 | 4.30000 | 4.28956 |
50.0 | 4.50000 | 4.46471 |
75.0 | 4.60000 | 4.63985 |
90.0 | 4.80000 | 4.79748 |
95.0 | 4.90000 | 4.89182 |
99.0 | 4.90000 | 5.06878 |
Step 5: PROC SQL - Advanced Queries
proc sql;
create table AvgPrice_Category as
select Category, mean(Price) as Avg_Price
from Electronics_Data
group by Category;
create table Top_Rated as
select Product_Name, Category, Ratings
from Electronics_Data
where Ratings > 4.6;
create table High_Consumption as
select * from Electronics_Data
where Power_Consumption > 50;
create table No_Of_Brands as
select Brand, count(*) as Product_Count
from Electronics_Data
group by Brand;
quit;
proc print data=AvgPrice_Category;
run;
Output:
Obs | Category | Avg_Price |
---|---|---|
1 | Laptop | 98332.33 |
2 | Mobile | 64999.00 |
3 | Speaker | 5249.00 |
4 | TV | 98332.33 |
5 | Tablet | 88332.33 |
6 | Watch | 22749.00 |
proc print data=Top_Rated;
run;
Output:
Obs | Product_Name | Category | Ratings |
---|---|---|---|
1 | MacBook_Pro | Laptop | 4.8 |
2 | ThinkPad_X1 | Laptop | 4.7 |
3 | iPhone_13 | Mobile | 4.9 |
4 | iPad_Pro | Tablet | 4.8 |
proc print data=High_Consumption;
run;
Output:
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | E002 | MacBook_Pro | Laptop | Apple | InStock | 129999 | 3 | 65 | 1.4 | 4.8 | 2022 |
2 | E003 | Bravia_4K | TV | Sony | OutOfStock | 84999 | 2 | 110 | 8.0 | 4.4 | 2020 |
3 | E008 | ThinkPad_X1 | Laptop | Lenovo | OutOfStock | 114999 | 3 | 60 | 1.2 | 4.7 | 2022 |
4 | E009 | OLED_TV | TV | LG | InStock | 134999 | 2 | 120 | 9.5 | 4.6 | 2021 |
5 | E014 | Realme_Book | Laptop | Realme | InStock | 49999 | 2 | 55 | 1.3 | 4.0 | 2023 |
6 | E015 | QLED_TV | TV | TCL | InStock | 74999 | 2 | 100 | 7.5 | 4.3 | 2022 |
proc print data=No_Of_Brands;
run;
Output:
Obs | Brand | Product_Count |
---|---|---|
1 | Amazon | 1 |
2 | Apple | 4 |
3 | 1 | |
4 | JBL | 1 |
5 | LG | 1 |
6 | Lenovo | 1 |
7 | Microsoft | 1 |
8 | OnePlus | 1 |
9 | Realme | 1 |
10 | Samsung | 2 |
11 | Sony | 1 |
12 | TCL | 1 |
13 | Xiaomi | 1 |
Step 6: SAS MACRO for Reusability
%macro TopDevices(cat=, n=5);
proc sql outobs=&n;
title "Top &n Expensive Devices in &cat Category";
select Product_Name, Price
from Electronics_Data
where Category = "&cat"
order by Price desc;
quit;
%mend;
%TopDevices(cat=Mobile, n=3);
Output:
Top 3 Expensive Devices in Mobile Category |
Product_Name | Price |
---|---|
iPhone_13 | 79999 |
Galaxy_S21 | 69999 |
Pixel_6 | 59999 |
%TopDevices(cat=TV, n=2);
Output:
Top 2 Expensive Devices in TV Category |
Product_Name | Price |
---|---|
OLED_TV | 134999 |
Bravia_4K | 84999 |
Step 7: PROC REPORT and PROC TABULATE
proc report data=Electronics_Data nowd;
column Category Brand Price Ratings;
define Category / group;
define Brand / group;
define Price / analysis mean;
define Ratings / analysis mean;
title "Average Price and Ratings by Brand and Category";
run;
Output:
Average Price and Ratings by Brand and Category |
Category | Brand | Price | Ratings |
---|---|---|---|
Laptop | Apple | 129999 | 4.8 |
Lenovo | 114999 | 4.7 | |
Realme | 49999 | 4 | |
Mobile | Apple | 79999 | 4.9 |
59999 | 4.5 | ||
OnePlus | 49999 | 4.4 | |
Samsung | 69999 | 4.5 | |
Speaker | Amazon | 3499 | 4.2 |
JBL | 6999 | 4.3 | |
TV | LG | 134999 | 4.6 |
Sony | 84999 | 4.4 | |
TCL | 74999 | 4.3 | |
Tablet | Apple | 109999 | 4.8 |
Microsoft | 99999 | 4.6 | |
Samsung | 54999 | 4.1 | |
Watch | Apple | 41999 | 4.6 |
Xiaomi | 3499 | 4.2 |
proc tabulate data=Electronics_Data;
class Category Brand;
var Price Ratings;
table Category, Brand*(Price Ratings)*mean;
title "Tabular View of Mean Price and Ratings";
run;
Output:
Tabular View of Mean Price and Ratings |
Brand | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Amazon | Apple | JBL | LG | Lenovo | Microsoft | OnePlus | Realme | Samsung | Sony | TCL | Xiaomi | |||||||||||||||
Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | Price | Ratings | |
Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | Mean | |
Category | . | . | 129999.00 | 4.80 | . | . | . | . | . | . | 114999.00 | 4.70 | . | . | . | . | 49999.00 | 4.00 | . | . | . | . | . | . | . | . |
Laptop | ||||||||||||||||||||||||||
Mobile | . | . | 79999.00 | 4.90 | 59999.00 | 4.50 | . | . | . | . | . | . | . | . | 49999.00 | 4.40 | . | . | 69999.00 | 4.50 | . | . | . | . | . | . |
Speaker | 3499.00 | 4.20 | . | . | . | . | 6999.00 | 4.30 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . |
TV | . | . | . | . | . | . | . | . | 134999.00 | 4.60 | . | . | . | . | . | . | . | . | . | . | 84999.00 | 4.40 | 74999.00 | 4.30 | . | . |
Tablet | . | . | 109999.00 | 4.80 | . | . | . | . | . | . | . | . | 99999.00 | 4.60 | . | . | . | . | 54999.00 | 4.10 | . | . | . | . | . | . |
Watch | . | . | 41999.00 | 4.60 | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | . | 3499.00 | 4.20 |
Step 8: PROC FORMAT and DATA Manipulation
proc format;
value $stockfmt
'InStock' = 'Available'
'OutOfStock' = 'Not Available';
value ratingfmt
low-4 = 'Low'
4<-4.5 = 'Medium'
4.5<-5 = 'High';
run;
data Electronics_Formatted;
set Electronics_Data;
format Availability $stockfmt. Ratings ratingfmt.;
run;
proc print data=Electronics_Formatted;
title "Electronics Dataset with Custom Formats";
run;
Output:
Electronics Dataset with Custom Formats |
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | E001 | Galaxy_S21 | Mobile | Samsung | Available | 69999 | 2 | 15 | 0.169 | Medium | 2021 |
2 | E002 | MacBook_Pro | Laptop | Apple | Available | 129999 | 3 | 65 | 1.400 | High | 2022 |
3 | E003 | Bravia_4K | TV | Sony | Not Available | 84999 | 2 | 110 | 8.000 | Medium | 2020 |
4 | E004 | Mi_Band_6 | Watch | Xiaomi | Available | 3499 | 1 | 5 | 0.035 | Medium | 2021 |
5 | E005 | Surface_Pro | Tablet | Microsoft | Available | 99999 | 2 | 30 | 0.800 | High | 2023 |
6 | E006 | JBL_Flip5 | Speaker | JBL | Available | 6999 | 1 | 10 | 0.500 | Medium | 2020 |
7 | E007 | OnePlus_9 | Mobile | OnePlus | Available | 49999 | 2 | 18 | 0.197 | Medium | 2021 |
8 | E008 | ThinkPad_X1 | Laptop | Lenovo | Not Available | 114999 | 3 | 60 | 1.200 | High | 2022 |
9 | E009 | OLED_TV | TV | LG | Available | 134999 | 2 | 120 | 9.500 | High | 2021 |
10 | E010 | Galaxy_Tab | Tablet | Samsung | Available | 54999 | 2 | 20 | 0.600 | Medium | 2022 |
11 | E011 | iPhone_13 | Mobile | Apple | Available | 79999 | 2 | 17 | 0.174 | High | 2022 |
12 | E012 | Pixel_6 | Mobile | Not Available | 59999 | 2 | 16 | 0.178 | Medium | 2021 | |
13 | E013 | Echo_Dot | Speaker | Amazon | Available | 3499 | 1 | 6 | 0.300 | Medium | 2020 |
14 | E014 | Realme_Book | Laptop | Realme | Available | 49999 | 2 | 55 | 1.300 | Low | 2023 |
15 | E015 | QLED_TV | TV | TCL | Available | 74999 | 2 | 100 | 7.500 | Medium | 2022 |
16 | E016 | iPad_Pro | Tablet | Apple | Not Available | 109999 | 2 | 25 | 0.700 | High | 2023 |
17 | E017 | Watch_Series_7 | Watch | Apple | Available | 41999 | 2 | 6 | 0.042 | High | 2022 |
Step 9: PROC SGPLOT - Visualization
proc sgplot data=Electronics_Data;
vbar Category / response=Price stat=mean;
title "Average Price by Electronics Category";
run;
Log:
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.71 seconds
cpu time 0.10 seconds
NOTE: Listing image output written to SGPlot1.png.
NOTE: There were 17 observations read from the data set WORK.ELECTRONICS_DATA.
proc sgplot data=Electronics_Data;
scatter x=Power_Consumption y=Ratings / group=Category;
title "Power vs Ratings by Category";
run;
Output:
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 0.48 seconds
cpu time 0.13 seconds
NOTE: Listing image output written to SGPlot3.png.
NOTE: There were 17 observations read from the data set WORK.ELECTRONICS_DATA.
Step 10: PROC TRANSPOSE and PROC RANK
proc sort data=Electronics_Data out=Sorted_Electronics;
by Product_ID;
run;
proc transpose data=Sorted_Electronics out=Transposed prefix=Device_;
by Product_ID;
id Category;
var Price;
run;
proc print;run;
Output:
Obs | Product_ID | _NAME_ | Device_Mobile | Device_Laptop | Device_TV | Device_Watch | Device_Tablet | Device_Speaker |
---|---|---|---|---|---|---|---|---|
1 | E001 | Price | 69999 | . | . | . | . | . |
2 | E002 | Price | . | 129999 | . | . | . | . |
3 | E003 | Price | . | . | 84999 | . | . | . |
4 | E004 | Price | . | . | . | 3499 | . | . |
5 | E005 | Price | . | . | . | . | 99999 | . |
6 | E006 | Price | . | . | . | . | . | 6999 |
7 | E007 | Price | 49999 | . | . | . | . | . |
8 | E008 | Price | . | 114999 | . | . | . | . |
9 | E009 | Price | . | . | 134999 | . | . | . |
10 | E010 | Price | . | . | . | . | 54999 | . |
11 | E011 | Price | 79999 | . | . | . | . | . |
12 | E012 | Price | 59999 | . | . | . | . | . |
13 | E013 | Price | . | . | . | . | . | 3499 |
14 | E014 | Price | . | 49999 | . | . | . | . |
15 | E015 | Price | . | . | 74999 | . | . | . |
16 | E016 | Price | . | . | . | . | 109999 | . |
17 | E017 | Price | . | . | . | 41999 | . | . |
proc rank data=Electronics_Data out=Ranked descending ties=low;
var Ratings;
ranks Rating_Rank;
run;
proc print data=Ranked;
title "Products Ranked by Ratings";
run;
Output:
Products Ranked by Ratings |
Obs | Product_ID | Product_Name | Category | Brand | Availability | Price | Warranty_Years | Power_Consumption | Weight | Ratings | Launch_Year | Rating_Rank |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | E001 | Galaxy_S21 | Mobile | Samsung | InStock | 69999 | 2 | 15 | 0.169 | 4.5 | 2021 | 8 |
2 | E002 | MacBook_Pro | Laptop | Apple | InStock | 129999 | 3 | 65 | 1.400 | 4.8 | 2022 | 2 |
3 | E003 | Bravia_4K | TV | Sony | OutOfStock | 84999 | 2 | 110 | 8.000 | 4.4 | 2020 | 10 |
4 | E004 | Mi_Band_6 | Watch | Xiaomi | InStock | 3499 | 1 | 5 | 0.035 | 4.2 | 2021 | 14 |
5 | E005 | Surface_Pro | Tablet | Microsoft | InStock | 99999 | 2 | 30 | 0.800 | 4.6 | 2023 | 5 |
6 | E006 | JBL_Flip5 | Speaker | JBL | InStock | 6999 | 1 | 10 | 0.500 | 4.3 | 2020 | 12 |
7 | E007 | OnePlus_9 | Mobile | OnePlus | InStock | 49999 | 2 | 18 | 0.197 | 4.4 | 2021 | 10 |
8 | E008 | ThinkPad_X1 | Laptop | Lenovo | OutOfStock | 114999 | 3 | 60 | 1.200 | 4.7 | 2022 | 4 |
9 | E009 | OLED_TV | TV | LG | InStock | 134999 | 2 | 120 | 9.500 | 4.6 | 2021 | 5 |
10 | E010 | Galaxy_Tab | Tablet | Samsung | InStock | 54999 | 2 | 20 | 0.600 | 4.1 | 2022 | 16 |
11 | E011 | iPhone_13 | Mobile | Apple | InStock | 79999 | 2 | 17 | 0.174 | 4.9 | 2022 | 1 |
12 | E012 | Pixel_6 | Mobile | OutOfStock | 59999 | 2 | 16 | 0.178 | 4.5 | 2021 | 8 | |
13 | E013 | Echo_Dot | Speaker | Amazon | InStock | 3499 | 1 | 6 | 0.300 | 4.2 | 2020 | 14 |
14 | E014 | Realme_Book | Laptop | Realme | InStock | 49999 | 2 | 55 | 1.300 | 4.0 | 2023 | 17 |
15 | E015 | QLED_TV | TV | TCL | InStock | 74999 | 2 | 100 | 7.500 | 4.3 | 2022 | 12 |
16 | E016 | iPad_Pro | Tablet | Apple | OutOfStock | 109999 | 2 | 25 | 0.700 | 4.8 | 2023 | 2 |
17 | E017 | Watch_Series_7 | Watch | Apple | InStock | 41999 | 2 | 6 | 0.042 | 4.6 | 2022 | 5 |
Step 11: PROC EXPORT - Export to Excel
proc export data=Electronics_Data
outfile="Electronics_Report.xlsx"
dbms=xlsx
replace;
sheet="Electronics";
run;
- Get link
- X
- Other Apps
Comments
Post a Comment