MODERN ELECTRONIC GADGETS DATA CREATION AND ANALYSIS USING PROC SQL | PROC MEANS | PROC UNIVARIATE | PROC SGPLOT | PROC RANK | MACROS WITH INTCK DERIVATIONS
options nodate nonumber nocenter;
1) Create gadgets dataset using DATA Step
data work.gadgets;
infile datalines dsd dlm='|';
length Model $40 Brand $20 Category $15 Release_Date $10;
input Model :$40. Brand :$20. Category :$15. RAM_GB Storage_GB Battery_mAh
Price_USD Rating Release_Date :$10.;
datalines;
iPhone 14 Pro|Apple|Phone|6|128|3200|999|4.6|2022-09-16
Galaxy S23|Samsung|Phone|8|256|3900|899|4.5|2023-02-17
Pixel 7|Google|Phone|8|128|4355|599|4.3|2022-10-13
MacBook Air M2|Apple|Laptop|8|256|5200|1199|4.7|2022-07-15
Dell XPS 13|Dell|Laptop|16|512|6000|999|4.4|2023-01-20
ThinkPad X1 Carbon|Lenovo|Laptop|16|1024|5800|1299|4.5|2022-09-05
Apple Watch Series 9|Apple|Smartwatch|1|32|300|399|4.6|2023-09-12
Galaxy Watch5|Samsung|Smartwatch|1|16|410|279|4.2|2022-08-26
AirPods Pro 2|Apple|Earbuds|1|1| |249|4.4|2022-09-23
Surface Pro 9|Microsoft|Tablet|8|256|5000|999|4.1|2023-10-03
OnePlus 11|OnePlus|Phone|12|256|5000|699|4.3|2023-02-07
Pixel Watch 2|Google|Smartwatch|1|32|306|299|4.0|2023-05-10
Oppo Find X6|Oppo|Phone|12|256|4800|749|4.1|2023-03-15
Huawei MateBook 14|Huawei|Laptop|16|512|5600|899|4.0|2022-11-25
Bose QC Earbuds|Bose|Earbuds|1|1| |279|4.2|2023-04-01
;
run;
proc print data=work.gadgets;
run;
OUTPUT:
| Obs | Model | Brand | Category | Release_Date | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating |
|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 2022-09-16 | 6 | 128 | 3200 | 999 | 4.6 |
| 2 | Galaxy S23 | Samsung | Phone | 2023-02-17 | 8 | 256 | 3900 | 899 | 4.5 |
| 3 | Pixel 7 | Phone | 2022-10-13 | 8 | 128 | 4355 | 599 | 4.3 | |
| 4 | MacBook Air M2 | Apple | Laptop | 2022-07-15 | 8 | 256 | 5200 | 1199 | 4.7 |
| 5 | Dell XPS 13 | Dell | Laptop | 2023-01-20 | 16 | 512 | 6000 | 999 | 4.4 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 2022-09-05 | 16 | 1024 | 5800 | 1299 | 4.5 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 2023-09-12 | 1 | 32 | 300 | 399 | 4.6 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 2022-08-26 | 1 | 16 | 410 | 279 | 4.2 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 2022-09-23 | 1 | 1 | . | 249 | 4.4 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 2023-10-03 | 8 | 256 | 5000 | 999 | 4.1 |
| 11 | OnePlus 11 | OnePlus | Phone | 2023-02-07 | 12 | 256 | 5000 | 699 | 4.3 |
| 12 | Pixel Watch 2 | Smartwatch | 2023-05-10 | 1 | 32 | 306 | 299 | 4.0 | |
| 13 | Oppo Find X6 | Oppo | Phone | 2023-03-15 | 12 | 256 | 4800 | 749 | 4.1 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 2022-11-25 | 16 | 512 | 5600 | 899 | 4.0 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 2023-04-01 | 1 | 1 | . | 279 | 4.2 |
2) Clean and enhance dataset
(convert Release_Date to SAS date, compute Battery_Life_est when missing, and other derived vars)
data work.gadgets;
set work.gadgets;
/* Convert Release_Date from ISO text to SAS date */
ReleaseDate = input(Release_Date, yymmdd10.);
format ReleaseDate yymmdd10.;
drop Release_Date;
/* Standardize missing numeric battery for earbuds: use typical battery-life estimates */
if Category = 'Earbuds' and (Battery_mAh = .) then do;
/* earbuds tend to have small internal batteries — estimate playback minutes */
Battery_mAh = 60;
end;
/* Derive Battery_Life_hours: a heuristic estimate (not measured hours) */
/* Use different heuristics by category */
length Battery_Life_hours 8;
if Category in: ('Phone') then Battery_Life_hours = round((Battery_mAh/400)*6, 0.1);
else if Category = 'Laptop' then Battery_Life_hours = round((Battery_mAh/600)*8, 0.1);
else if Category = 'Smartwatch' then Battery_Life_hours = round((Battery_mAh/100)*1.2, 0.1);
else if Category = 'Earbuds' then Battery_Life_hours = round((Battery_mAh/60)*6, 0.1);
else Battery_Life_hours = .;
/* Device age in months from ReleaseDate to today */
Device_Age_Months = intck('month', ReleaseDate, today());
/* Price per GB of RAM (simple affordability metric) */
if RAM_GB > 0 then Price_per_RAM = round(Price_USD / RAM_GB, 0.01);
else Price_per_RAM = .;
/* Create numeric Rating_Scaled 0-100 for easier scoring */
Rating_Scaled = round(Rating * 20, 1);
format Battery_Life_hours 6.1 Price_per_RAM 6.2 Rating_Scaled 6.1;
run;
proc print data=work.gadgets;
run;
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 |
3) A macro to compute a composite Performance Score with configurable weights
%macro perf_score(in=work.gadgets, out=work.gadgets_scored, w_ram=0.25,
w_batt=0.30, w_storage=0.15, w_price=0.15, w_rating=0.15);
data &out.;
set &in.;
/* Normalize components to 0-100 before weighting */
/* We'll use winsorized bounds to reduce effect of outliers */
/* For simplicity compute theoretical maxs (could be computed dynamically with PROC SQL) */
max_ram = 16; /* typical upper bound used here */
max_batt = 6000;
max_storage = 1024;
min_price = 199; /* lower bound for normalization */
max_price = 1299;
/* Normalize each metric 0-100 */
ram_norm = min(100, max(0, (RAM_GB / max_ram) * 100));
batt_norm = min(100, max(0, (Battery_mAh / max_batt) * 100));
stor_norm = min(100, max(0, (Storage_GB / max_storage) * 100));
/* For price, lower price is better — invert */
if Price_USD >= max_price then price_norm = 0;
else if Price_USD <= min_price then price_norm = 100;
else price_norm = 100 * (max_price - Price_USD) / (max_price - min_price);
rating_norm = min(100, max(0, Rating_Scaled));
/* Composite score */
Performance_Score = round(ram_norm*&w_ram. + batt_norm*&w_batt. + stor_norm*&w_storage. + price_norm*&w_price. + rating_norm*&w_rating., 0.1);
label ram_norm = 'RAM (0-100)'
batt_norm = 'Battery (0-100)'
stor_norm = 'Storage (0-100)'
price_norm = 'Price (inverted, 0-100)'
rating_norm = 'Rating (0-100)'
Performance_Score = 'Composite Performance Score';
run;
proc print;
run;
%mend perf_score;
4) Run the scoring macro multiple times with different weight sets to show repeated performance scoring
%perf_score(in=work.gadgets, out=work.gadgets_score_default);
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled | max_ram | max_batt | max_storage | min_price | max_price | ram_norm | batt_norm | stor_norm | price_norm | rating_norm | Performance_Score |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 37.50 | 53.333 | 12.500 | 27.2727 | 92 | 45.1 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 65.000 | 25.000 | 36.3636 | 90 | 54.7 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 72.583 | 12.500 | 63.6364 | 86 | 58.6 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 86.667 | 25.000 | 9.0909 | 94 | 57.7 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 100.000 | 50.000 | 27.2727 | 88 | 79.8 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 96.667 | 100.000 | 0.0000 | 90 | 82.5 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.000 | 3.125 | 81.8182 | 92 | 29.6 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 6.833 | 1.563 | 92.7273 | 84 | 30.4 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 95.4545 | 88 | 29.4 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 83.333 | 25.000 | 27.2727 | 82 | 57.6 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 83.333 | 25.000 | 54.5455 | 86 | 68.6 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.100 | 3.125 | 90.9091 | 80 | 29.2 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 80.000 | 25.000 | 50.0000 | 82 | 66.3 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 93.333 | 50.000 | 36.3636 | 80 | 78.0 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 92.7273 | 84 | 28.4 |
%perf_score(in=work.gadgets, out=work.gadgets_score_batt_focused, w_ram=0.15, w_batt=0.50, w_storage=0.10, w_price=0.10, w_rating=0.15);
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled | max_ram | max_batt | max_storage | min_price | max_price | ram_norm | batt_norm | stor_norm | price_norm | rating_norm | Performance_Score |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 37.50 | 53.333 | 12.500 | 27.2727 | 92 | 50.1 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 65.000 | 25.000 | 36.3636 | 90 | 59.6 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 72.583 | 12.500 | 63.6364 | 86 | 64.3 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 86.667 | 25.000 | 9.0909 | 94 | 68.3 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 100.000 | 50.000 | 27.2727 | 88 | 85.9 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 96.667 | 100.000 | 0.0000 | 90 | 86.8 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.000 | 3.125 | 81.8182 | 92 | 25.7 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 6.833 | 1.563 | 92.7273 | 84 | 26.4 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 95.4545 | 88 | 24.2 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 83.333 | 25.000 | 27.2727 | 82 | 66.7 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 83.333 | 25.000 | 54.5455 | 86 | 73.8 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.100 | 3.125 | 90.9091 | 80 | 24.9 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 80.000 | 25.000 | 50.0000 | 82 | 71.1 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 93.333 | 50.000 | 36.3636 | 80 | 82.3 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 92.7273 | 84 | 23.3 |
%perf_score(in=work.gadgets, out=work.gadgets_score_budget_focused, w_ram=0.10, w_batt=0.20, w_storage=0.10, w_price=0.40, w_rating=0.20);
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled | max_ram | max_batt | max_storage | min_price | max_price | ram_norm | batt_norm | stor_norm | price_norm | rating_norm | Performance_Score |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 37.50 | 53.333 | 12.500 | 27.2727 | 92 | 45.0 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 65.000 | 25.000 | 36.3636 | 90 | 53.0 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 72.583 | 12.500 | 63.6364 | 86 | 63.4 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 86.667 | 25.000 | 9.0909 | 94 | 47.3 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 100.000 | 50.000 | 27.2727 | 88 | 63.5 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 96.667 | 100.000 | 0.0000 | 90 | 57.3 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.000 | 3.125 | 81.8182 | 92 | 53.1 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 6.833 | 1.563 | 92.7273 | 84 | 56.0 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 95.4545 | 88 | 56.6 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 83.333 | 25.000 | 27.2727 | 82 | 51.5 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 83.333 | 25.000 | 54.5455 | 86 | 65.7 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.100 | 3.125 | 90.9091 | 80 | 54.3 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 80.000 | 25.000 | 50.0000 | 82 | 62.4 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 93.333 | 50.000 | 36.3636 | 80 | 64.2 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 92.7273 | 84 | 54.7 |
5) Use PROC RANK to create rank order by Performance_Score
proc rank data=work.gadgets_score_default out=work.gadgets_ranked_default ties=low descending;
var Performance_Score;
ranks Perf_Rank_Default;
run;
proc print data=work.gadgets_ranked_default;
run;
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled | max_ram | max_batt | max_storage | min_price | max_price | ram_norm | batt_norm | stor_norm | price_norm | rating_norm | Performance_Score | Perf_Rank_Default |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 37.50 | 53.333 | 12.500 | 27.2727 | 92 | 45.1 | 10 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 65.000 | 25.000 | 36.3636 | 90 | 54.7 | 9 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 72.583 | 12.500 | 63.6364 | 86 | 58.6 | 6 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 86.667 | 25.000 | 9.0909 | 94 | 57.7 | 7 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 100.000 | 50.000 | 27.2727 | 88 | 79.8 | 2 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 96.667 | 100.000 | 0.0000 | 90 | 82.5 | 1 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.000 | 3.125 | 81.8182 | 92 | 29.6 | 12 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 6.833 | 1.563 | 92.7273 | 84 | 30.4 | 11 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 95.4545 | 88 | 29.4 | 13 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 83.333 | 25.000 | 27.2727 | 82 | 57.6 | 8 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 83.333 | 25.000 | 54.5455 | 86 | 68.6 | 4 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.100 | 3.125 | 90.9091 | 80 | 29.2 | 14 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 80.000 | 25.000 | 50.0000 | 82 | 66.3 | 5 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 93.333 | 50.000 | 36.3636 | 80 | 78.0 | 3 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 92.7273 | 84 | 28.4 | 15 |
proc rank data=work.gadgets_score_batt_focused out=work.gadgets_ranked_batt ties=low descending;
var Performance_Score;
ranks Perf_Rank_Batt;
run;
proc print data=work.gadgets_ranked_batt;
run;
OUTPUT:
| Obs | Model | Brand | Category | RAM_GB | Storage_GB | Battery_mAh | Price_USD | Rating | ReleaseDate | Battery_Life_hours | Device_Age_Months | Price_per_RAM | Rating_Scaled | max_ram | max_batt | max_storage | min_price | max_price | ram_norm | batt_norm | stor_norm | price_norm | rating_norm | Performance_Score | Perf_Rank_Batt |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | iPhone 14 Pro | Apple | Phone | 6 | 128 | 3200 | 999 | 4.6 | 2022-09-16 | 48.0 | 38 | 166.50 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 37.50 | 53.333 | 12.500 | 27.2727 | 92 | 50.1 | 10 |
| 2 | Galaxy S23 | Samsung | Phone | 8 | 256 | 3900 | 899 | 4.5 | 2023-02-17 | 58.5 | 33 | 112.38 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 65.000 | 25.000 | 36.3636 | 90 | 59.6 | 9 |
| 3 | Pixel 7 | Phone | 8 | 128 | 4355 | 599 | 4.3 | 2022-10-13 | 65.3 | 37 | 74.88 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 72.583 | 12.500 | 63.6364 | 86 | 64.3 | 8 | |
| 4 | MacBook Air M2 | Apple | Laptop | 8 | 256 | 5200 | 1199 | 4.7 | 2022-07-15 | 69.3 | 40 | 149.88 | 94.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 86.667 | 25.000 | 9.0909 | 94 | 68.3 | 6 |
| 5 | Dell XPS 13 | Dell | Laptop | 16 | 512 | 6000 | 999 | 4.4 | 2023-01-20 | 80.0 | 34 | 62.44 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 100.000 | 50.000 | 27.2727 | 88 | 85.9 | 2 |
| 6 | ThinkPad X1 Carbon | Lenovo | Laptop | 16 | 1024 | 5800 | 1299 | 4.5 | 2022-09-05 | 77.3 | 38 | 81.19 | 90.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 96.667 | 100.000 | 0.0000 | 90 | 86.8 | 1 |
| 7 | Apple Watch Series 9 | Apple | Smartwatch | 1 | 32 | 300 | 399 | 4.6 | 2023-09-12 | 3.6 | 26 | 399.00 | 92.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.000 | 3.125 | 81.8182 | 92 | 25.7 | 12 |
| 8 | Galaxy Watch5 | Samsung | Smartwatch | 1 | 16 | 410 | 279 | 4.2 | 2022-08-26 | 4.9 | 39 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 6.833 | 1.563 | 92.7273 | 84 | 26.4 | 11 |
| 9 | AirPods Pro 2 | Apple | Earbuds | 1 | 1 | 60 | 249 | 4.4 | 2022-09-23 | 6.0 | 38 | 249.00 | 88.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 95.4545 | 88 | 24.2 | 14 |
| 10 | Surface Pro 9 | Microsoft | Tablet | 8 | 256 | 5000 | 999 | 4.1 | 2023-10-03 | . | 25 | 124.88 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 50.00 | 83.333 | 25.000 | 27.2727 | 82 | 66.7 | 7 |
| 11 | OnePlus 11 | OnePlus | Phone | 12 | 256 | 5000 | 699 | 4.3 | 2023-02-07 | 75.0 | 33 | 58.25 | 86.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 83.333 | 25.000 | 54.5455 | 86 | 73.8 | 4 |
| 12 | Pixel Watch 2 | Smartwatch | 1 | 32 | 306 | 299 | 4.0 | 2023-05-10 | 3.7 | 30 | 299.00 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 5.100 | 3.125 | 90.9091 | 80 | 24.9 | 13 | |
| 13 | Oppo Find X6 | Oppo | Phone | 12 | 256 | 4800 | 749 | 4.1 | 2023-03-15 | 72.0 | 32 | 62.42 | 82.0 | 16 | 6000 | 1024 | 199 | 1299 | 75.00 | 80.000 | 25.000 | 50.0000 | 82 | 71.1 | 5 |
| 14 | Huawei MateBook 14 | Huawei | Laptop | 16 | 512 | 5600 | 899 | 4.0 | 2022-11-25 | 74.7 | 36 | 56.19 | 80.0 | 16 | 6000 | 1024 | 199 | 1299 | 100.00 | 93.333 | 50.000 | 36.3636 | 80 | 82.3 | 3 |
| 15 | Bose QC Earbuds | Bose | Earbuds | 1 | 1 | 60 | 279 | 4.2 | 2023-04-01 | 6.0 | 31 | 279.00 | 84.0 | 16 | 6000 | 1024 | 199 | 1299 | 6.25 | 1.000 | 0.098 | 92.7273 | 84 | 23.3 | 15 |
proc means data=work.gadgets_score_default mean median std min max n;
var RAM_GB Storage_GB Battery_mAh Battery_Life_hours Price_USD Rating_Scaled Performance_Score;
title 'Numeric Summary: GADGETS (Default Performance Score)';
run;
OUTPUT:
The MEANS Procedure
| Variable | Label | Mean | Median | Std Dev | Minimum | Maximum | N |
|---|---|---|---|---|---|---|---|
RAM_GB Storage_GB Battery_mAh Battery_Life_hours Price_USD Rating_Scaled Performance_Score | Composite Performance Score | 7.6666667 244.4000000 3332.73 46.0214286 723.0000000 86.5333333 53.0600000 | 8.0000000 256.0000000 4355.00 61.9000000 749.0000000 86.0000000 57.6000000 | 5.8022984 272.5078767 2379.20 32.8496149 355.4835741 4.5018515 19.9292965 | 1.0000000 1.0000000 60.0000000 3.6000000 249.0000000 80.0000000 28.4000000 | 16.0000000 1024.00 6000.00 80.0000000 1299.00 94.0000000 82.5000000 | 15 15 15 14 15 15 15 |
proc univariate data=work.gadgets_score_default;
var Performance_Score Price_USD Battery_Life_hours;
histogram Performance_Score / normal;
inset mean std median / position=ne;
title 'Univariate Analysis for Key Metrics';
run;
title;
OUTPUT:
The UNIVARIATE Procedure
Variable: Performance_Score (Composite Performance Score)
| Moments | |||
|---|---|---|---|
| N | 15 | Sum Weights | 15 |
| Mean | 53.06 | Sum Observations | 795.9 |
| Std Deviation | 19.9292965 | Variance | 397.176857 |
| Skewness | -0.0029729 | Kurtosis | -1.4578113 |
| Uncorrected SS | 47790.93 | Corrected SS | 5560.476 |
| Coeff Variation | 37.5599255 | Std Error Mean | 5.14572222 |
| Basic Statistical Measures | |||
|---|---|---|---|
| Location | Variability | ||
| Mean | 53.06000 | Std Deviation | 19.92930 |
| Median | 57.60000 | Variance | 397.17686 |
| Mode | . | Range | 54.10000 |
| Interquartile Range | 39.00000 | ||
| Tests for Location: Mu0=0 | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Student's t | t | 10.31148 | Pr > |t| | <.0001 |
| Sign | M | 7.5 | Pr >= |M| | <.0001 |
| Signed Rank | S | 60 | Pr >= |S| | <.0001 |
| Quantiles (Definition 5) | |
|---|---|
| Level | Quantile |
| 100% Max | 82.5 |
| 99% | 82.5 |
| 95% | 82.5 |
| 90% | 79.8 |
| 75% Q3 | 68.6 |
| 50% Median | 57.6 |
| 25% Q1 | 29.6 |
| 10% | 29.2 |
| 5% | 28.4 |
| 1% | 28.4 |
| 0% Min | 28.4 |
| Extreme Observations | |||
|---|---|---|---|
| Lowest | Highest | ||
| Value | Obs | Value | Obs |
| 28.4 | 15 | 66.3 | 13 |
| 29.2 | 12 | 68.6 | 11 |
| 29.4 | 9 | 78.0 | 14 |
| 29.6 | 7 | 79.8 | 5 |
| 30.4 | 8 | 82.5 | 6 |
The UNIVARIATE Procedure
The UNIVARIATE Procedure
Fitted Normal Distribution for Performance_Score (Composite Performance Score)
| Parameters for Normal Distribution | ||
|---|---|---|
| Parameter | Symbol | Estimate |
| Mean | Mu | 53.06 |
| Std Dev | Sigma | 19.9293 |
| Goodness-of-Fit Tests for Normal Distribution | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Kolmogorov-Smirnov | D | 0.20556828 | Pr > D | 0.087 |
| Cramer-von Mises | W-Sq | 0.08370795 | Pr > W-Sq | 0.176 |
| Anderson-Darling | A-Sq | 0.61317932 | Pr > A-Sq | 0.092 |
| Quantiles for Normal Distribution | ||
|---|---|---|
| Percent | Quantile | |
| Observed | Estimated | |
| 1.0 | 28.4000 | 6.69752 |
| 5.0 | 28.4000 | 20.27922 |
| 10.0 | 29.2000 | 27.51958 |
| 25.0 | 29.6000 | 39.61789 |
| 50.0 | 57.6000 | 53.06000 |
| 75.0 | 68.6000 | 66.50211 |
| 90.0 | 79.8000 | 78.60042 |
| 95.0 | 82.5000 | 85.84078 |
| 99.0 | 82.5000 | 99.42248 |
The UNIVARIATE Procedure
Variable: Price_USD
| Moments | |||
|---|---|---|---|
| N | 15 | Sum Weights | 15 |
| Mean | 723 | Sum Observations | 10845 |
| Std Deviation | 355.483574 | Variance | 126368.571 |
| Skewness | -0.0380933 | Kurtosis | -1.3433761 |
| Uncorrected SS | 9610095 | Corrected SS | 1769160 |
| Coeff Variation | 49.1678526 | Std Error Mean | 91.7854641 |
| Basic Statistical Measures | |||
|---|---|---|---|
| Location | Variability | ||
| Mean | 723.0000 | Std Deviation | 355.48357 |
| Median | 749.0000 | Variance | 126369 |
| Mode | 999.0000 | Range | 1050 |
| Interquartile Range | 700.00000 | ||
| Tests for Location: Mu0=0 | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Student's t | t | 7.877064 | Pr > |t| | <.0001 |
| Sign | M | 7.5 | Pr >= |M| | <.0001 |
| Signed Rank | S | 60 | Pr >= |S| | <.0001 |
| Quantiles (Definition 5) | |
|---|---|
| Level | Quantile |
| 100% Max | 1299 |
| 99% | 1299 |
| 95% | 1299 |
| 90% | 1199 |
| 75% Q3 | 999 |
| 50% Median | 749 |
| 25% Q1 | 299 |
| 10% | 279 |
| 5% | 249 |
| 1% | 249 |
| 0% Min | 249 |
| Extreme Observations | |||
|---|---|---|---|
| Lowest | Highest | ||
| Value | Obs | Value | Obs |
| 249 | 9 | 999 | 1 |
| 279 | 15 | 999 | 5 |
| 279 | 8 | 999 | 10 |
| 299 | 12 | 1199 | 4 |
| 399 | 7 | 1299 | 6 |
The UNIVARIATE Procedure
Variable: Battery_Life_hours
| Moments | |||
|---|---|---|---|
| N | 14 | Sum Weights | 14 |
| Mean | 46.0214286 | Sum Observations | 644.3 |
| Std Deviation | 32.8496149 | Variance | 1079.0972 |
| Skewness | -0.4882833 | Kurtosis | -1.8419884 |
| Uncorrected SS | 43679.87 | Corrected SS | 14028.2636 |
| Coeff Variation | 71.3789552 | Std Error Mean | 8.77942887 |
| Basic Statistical Measures | |||
|---|---|---|---|
| Location | Variability | ||
| Mean | 46.02143 | Std Deviation | 32.84961 |
| Median | 61.90000 | Variance | 1079 |
| Mode | 6.00000 | Range | 76.40000 |
| Interquartile Range | 68.70000 | ||
| Tests for Location: Mu0=0 | ||||
|---|---|---|---|---|
| Test | Statistic | p Value | ||
| Student's t | t | 5.241962 | Pr > |t| | 0.0002 |
| Sign | M | 7 | Pr >= |M| | 0.0001 |
| Signed Rank | S | 52.5 | Pr >= |S| | 0.0001 |
| Quantiles (Definition 5) | |
|---|---|
| Level | Quantile |
| 100% Max | 80.0 |
| 99% | 80.0 |
| 95% | 80.0 |
| 90% | 77.3 |
| 75% Q3 | 74.7 |
| 50% Median | 61.9 |
| 25% Q1 | 6.0 |
| 10% | 3.7 |
| 5% | 3.6 |
| 1% | 3.6 |
| 0% Min | 3.6 |
| Extreme Observations | |||
|---|---|---|---|
| Lowest | Highest | ||
| Value | Obs | Value | Obs |
| 3.6 | 7 | 72.0 | 13 |
| 3.7 | 12 | 74.7 | 14 |
| 4.9 | 8 | 75.0 | 11 |
| 6.0 | 15 | 77.3 | 6 |
| 6.0 | 9 | 80.0 | 5 |
| Missing Values | |||
|---|---|---|---|
| Missing Value | Count | Percent Of | |
| All Obs | Missing Obs | ||
| . | 1 | 6.67 | 100.00 |
7) PROC SQL examples: Top 5 by default performance score and average price by category */
proc sql outobs=5;
create table work.top5_default as
select Model, Brand, Category, Performance_Score, Price_USD
from work.gadgets_ranked_default
order by Perf_Rank_Default;
create table work.avg_price_by_cat as
select Category, count(*) as Count, mean(Price_USD) as Avg_Price format=8.2
from work.gadgets_score_default
group by Category;
quit;
proc print data=work.top5_default;
run;
OUTPUT:
| Obs | Model | Brand | Category | Performance_Score | Price_USD |
|---|---|---|---|---|---|
| 1 | ThinkPad X1 Carbon | Lenovo | Laptop | 82.5 | 1299 |
| 2 | Dell XPS 13 | Dell | Laptop | 79.8 | 999 |
| 3 | Huawei MateBook 14 | Huawei | Laptop | 78.0 | 899 |
| 4 | OnePlus 11 | OnePlus | Phone | 68.6 | 699 |
| 5 | Oppo Find X6 | Oppo | Phone | 66.3 | 749 |
proc print data=work.avg_price_by_cat;
run;
OUTPUT:
| Obs | Category | Count | Avg_Price |
|---|---|---|---|
| 1 | Earbuds | 2 | 264.00 |
| 2 | Laptop | 4 | 1099.00 |
| 3 | Phone | 5 | 789.00 |
| 4 | Smartwatch | 3 | 325.67 |
| 5 | Tablet | 1 | 999.00 |
8) Visualizations using PROC SGPLOT
proc sgplot data=work.gadgets_score_default;
scatter x=Price_USD y=Performance_Score / datalabel=Model markerattrs=(symbol=CircleFilled);
reg x=Price_USD y=Performance_Score; /* trend line */
xaxis label='Price (USD)';
yaxis label='Performance Score (0-100)';
title 'Price vs Performance Score';
run;
OUTPUT:
proc sgplot data=work.gadgets_score_default;
vbar Category / response=Performance_Score stat=mean datalabel;
title 'Average Performance Score by Category';
run;
OUTPUT:
9) Demonstrate INTCK usage again — months since release for reporting
proc sql;
create table work.age_report as
select Model, Brand, Category, ReleaseDate,
intck('month', ReleaseDate, today()) as Age_Months
from work.gadgets_score_default
order by Age_Months desc;
quit;
proc print data=work.age_report;
run;
| Obs | Model | Brand | Category | ReleaseDate | Age_Months |
|---|---|---|---|---|---|
| 1 | MacBook Air M2 | Apple | Laptop | 2022-07-15 | 40 |
| 2 | Galaxy Watch5 | Samsung | Smartwatch | 2022-08-26 | 39 |
| 3 | ThinkPad X1 Carbon | Lenovo | Laptop | 2022-09-05 | 38 |
| 4 | iPhone 14 Pro | Apple | Phone | 2022-09-16 | 38 |
| 5 | AirPods Pro 2 | Apple | Earbuds | 2022-09-23 | 38 |
| 6 | Pixel 7 | Phone | 2022-10-13 | 37 | |
| 7 | Huawei MateBook 14 | Huawei | Laptop | 2022-11-25 | 36 |
| 8 | Dell XPS 13 | Dell | Laptop | 2023-01-20 | 34 |
| 9 | Galaxy S23 | Samsung | Phone | 2023-02-17 | 33 |
| 10 | OnePlus 11 | OnePlus | Phone | 2023-02-07 | 33 |
| 11 | Oppo Find X6 | Oppo | Phone | 2023-03-15 | 32 |
| 12 | Bose QC Earbuds | Bose | Earbuds | 2023-04-01 | 31 |
| 13 | Pixel Watch 2 | Smartwatch | 2023-05-10 | 30 | |
| 14 | Apple Watch Series 9 | Apple | Smartwatch | 2023-09-12 | 26 |
| 15 | Surface Pro 9 | Microsoft | Tablet | 2023-10-03 | 25 |
No comments:
Post a Comment